Skip to content

perf(agc): publish storage-image results into resident heap mirrors - #17796

Merged
oneandonlydean merged 6 commits into
boykopovar:mainfrom
ashwin280802:perf/agc-storage-image-mirror-publish
Nov 19, 2026
Merged

oneandonlydean merged 6 commits into
boykopovar:mainfrom
ashwin280802:perf/agc-storage-image-mirror-publish

Conversation

@ashwin280802

@ashwin280802 ashwin280802 commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

What

When an address-based build refreshes a resident heap mirror, pending storage images inside it are no longer stored back to guest memory first. Their pending units are retiled on the GPU into the mirror, so the build reads the results without a CPU round trip. The images stay pending: a hooked CPU read, a label or an idle store writes guest memory as before. Blocks the CPU or another store wrote since a unit's generation are left out, as in the write-back. DCC keys that do not read uncompressed, partly drawn rectangles, read traps, unwatched memory, copied heap mirrors and ranges the build itself writes fall back to the old store. APS5_NO_MIRROR_PUBLISH=1 restores the old path; the debt entry lists what stays unproven.

Overlap: 79 open PRs could not be checked automatically. By title none implements this; #13251 (storage image units on the device) is closest, and #15296 touches the same mirror code.

Tested

Windows 11 10.0.26300, MinGW UCRT64 GCC, NVIDIA GeForce RTX 5070 (driver 617.42), commit faf7f5a2650481abb11e5392d7267cb9d76b7739.

ctest --test-dir build-full -R "^agc_driver_(resident_heap_mirror|address_draw_space_reuse)" --output-on-failure

2/7 Test #1740: agc_driver_resident_heap_mirror ...................   Passed    0.69 sec
7/7 Test #2463: agc_driver_resident_heap_mirror_no_publish ........   Passed    0.58 sec
100% tests passed out of 7

The tests check that a published image leaves guest memory untouched yet reads back through the hook, that unchanged rebuilds skip the publish, that CPU writes win, that DCC images with uncompressed keys publish and that writable and copied mirrors fall back; _no_publish is the negative control.

With ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, the same tests on main (9d2e737, built here) and the change; the new negative control has no main counterpart and ran on the change alone:

RESULT: PASS
layer: loaded
diagnostics: change 0, baseline 0, new 0

The full Windows suite passed except tests that also fail on main here (vulkan_validation_gate_commands; guest_timed_join_import_libkernel_web, fixed on main by 07572f5). Linux (llvmpipe, 0 failures) and ASan ran on the revision before the last two fixes, not on this commit. I changed 20 conditions one at a time: 10 failed the tests, 1 did not build; of the other 9, five are equivalent, diagnostic or lifetime guards and four are the untested paths below.

Speed, Jusant (PPSA10264). It needs #8089 to run, so both sides are one build of this patch on top of #8089 with publishing on and off (APS5_NO_MIRROR_PUBLISH=1 stores as main does). Measured on the revision before the last fix, which only changes what happens when a mirror is evicted during the build.

Guest flips per 10 s, ABBA:

Run Mode Last 6 Windows (Flips / 10 s) Mean Presents Equal Flips
01-change Change 32, 31, 31, 32, 31, 31 31.3 True
02-off Publishing off 14, 14, 14, 14, 14, 14 14.0 True
03-off Publishing off 14, 14, 14, 14, 14, 15 14.2 True
04-change Change 29, 28, 28, 28, 28, 28 28.2 True

APS5_TRACE_SECONDS=200:20 captures, warm caches, no other trace or profile switch (tools/trace_digest.py):

Mode Present Window Presents (20 s) Frame p50 Frame p90 Frame p99 Max GPU Busy (ms/present)
Change seconds 200:20 from present 348 57 351.9 ms 374.2 ms 545.9 ms 545.9 ms 147.6 ms
Publishing off seconds 200:20 from present 153 30 672.7 ms 692.6 ms 729.9 ms 729.9 ms 151.6 ms

Phase breakdown (draw committer thread):

Mode Phase Duration (% Frame) Self (%) Slices Wait Sub-phases
Change draw committer 176.0 ms (49 %) 35.9 ms (10 %) 143.9 1.7 Graphics.Draw 101.4, Recorder.Sync 81.0
Publishing off draw committer 422.6 ms (63 %) 111.9 ms (17 %) 137.5 2.3 Graphics.Draw 368.9, Recorder.Sync 133.4

Change first, publishing off second. GPU time is unchanged; the gain is the CPU store-backs the build no longer waits for. Traces: change aps5-trace-475c6eb5d3ff-25588.json.gz, publishing off aps5-trace-475c6eb5d3ff-43440.json.gz.

Summary lines (aps5-summary.jsonl, one per capture, in the order above):

{"commit":"475c6eb5d3ff","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_SECONDS":"200:20"},"gpu":"NVIDIA GeForce RTX 5070","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","cpu":"Intel(R) Core(TM) i5-14600K","cpu_threads":20,"memory_mib":16147,"title_id":"PPSA10264","title":"Jusant","content_version":"02.000.000","resolution":"3840x2160","window":{"spec":"seconds 200:20","first_present":348,"ms":20280.093},"presents":57,"frame_ms":{"p50":351.917,"p90":374.204,"p99":545.87,"max":545.87},"gpu_busy_ms_per_present":147.635,"worker_busy_pct":{"queue worker 0x0":98.335,"queue worker 0x20":75.629},"top_phases_ms_per_frame":{"Driver.Packet":613.356,"Driver.Packet.dispatch":293.082,"Driver.Dispatch":185.387,"Recorder.Sync":137.559,"Graphics.Draw":111.687,"Graphics.Draw.draw_and_resource_release":104.057,"Resources.Complete":88.254,"Driver.Packet.prepare_memory":85.999},"trace_dropped":false,"trace":"aps5-trace-475c6eb5d3ff-25588.json.gz"}
{"commit":"9d2e737432d","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_SECONDS":"200:20"},"gpu":"NVIDIA GeForce RTX 5070","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","cpu":"Intel(R) Core(TM) i5-14600K","cpu_threads":20,"memory_mib":16147,"title_id":"PPSA10264","title":"Jusant","content_version":"02.000.000","resolution":"3840x2160","window":{"spec":"seconds 200:20","first_present":153,"ms":20161.35},"presents":30,"frame_ms":{"p50":672.733,"p90":692.634,"p99":729.904,"max":729.904},"gpu_busy_ms_per_present":151.647,"worker_busy_pct":{"queue worker 0x0":97.477,"queue worker 0x20":66.991},"top_phases_ms_per_frame":{"Driver.Packet":1099.931,"Driver.Packet.dispatch":461.8,"Graphics.Draw":379.564,"Graphics.Draw.draw_and_resource_release":372.194,"Driver.Dispatch":272.052,"Driver.Packet.pipeline_drain":184.101,"Driver.Packet.prepare_memory":181.467,"Recorder.Sync":176.318},"trace_dropped":false,"trace":"aps5-trace-475c6eb5d3ff-43440.json.gz"}

Not verified: on a console; on GPUs other than this one; Jusant on plain main (it does not run without #8089).
Not covered by a test: the publish drain of a reused address-based build (GuestBufferMemory::RecordStagingCopies); a heap mirror evicted by the same build after an image was deferred into it (the publish then finds the mirror gone by base and serial and stores the image instead); images outside the write watch, array layers, multiple mips, edge blocks and memo eviction. Devices without sparse residency never publish; there the negative control skips.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 5070, driver 617.42, Windows 11 10.0.26300
  • AI-assisted: yes

🤖 Generated with Claude Code

While a resident heap mirror's run is refreshed, pending storage images
overlapping it are no longer stored back to guest memory. Their pending
units are retiled on the GPU into the mirror after the shadow flush;
blocks the CPU or another store wrote since the unit's generation are
left out. Images stay pending, so CPU readers, labels and idle stores
behave as before. Unsupported cases fall back to the old store and are
counted by reason. APS5_NO_MIRROR_PUBLISH=1 restores the old path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added build docs agc libSceAgc* perf Performance change perf numbers missing perf pull request without a before and after summary line labels Nov 9, 2026
@oneandonlydean oneandonlydean self-assigned this Nov 9, 2026
@github-actions

github-actions Bot commented Nov 9, 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 21238 docs/dev/ENVIRONMENT.md L372
PR 21669 core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp L1123-1130
PR 22438 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp L5216
PR 23234 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp L420

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/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 1395 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 1896 docs/dev/ENVIRONMENT.md
PR 4448 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/debt/libSceAgcDriver.md
PR 4472 docs/dev/ENVIRONMENT.md
PR 5372 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/debt/libSceAgcDriver.md
PR 5609 core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 5925 docs/dev/debt/libSceAgcDriver.md
PR 6186 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 6188 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6192 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6197 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6209 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6280 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6412 docs/dev/debt/libSceAgcDriver.md
PR 6481 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6804 docs/dev/debt/libSceAgcDriver.md
PR 6808 docs/dev/debt/libSceAgcDriver.md
PR 6924 docs/dev/ENVIRONMENT.md
PR 7085 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 7256 docs/dev/debt/libSceAgcDriver.md
PR 7275 docs/dev/ENVIRONMENT.md
PR 7642 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ResidentMirror.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 7643 docs/dev/ENVIRONMENT.md
PR 8246 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/ENVIRONMENT.md
PR 8592 docs/dev/debt/libSceAgcDriver.md
PR 9345 docs/dev/ENVIRONMENT.md
PR 9356 core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 9387 core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 9508 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/ResidentMirror.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ResidentMirror.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 9712 core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
docs/dev/ENVIRONMENT.md
PR 9852 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/ENVIRONMENT.md
PR 9895 docs/dev/debt/libSceAgcDriver.md
PR 9950 docs/dev/debt/libSceAgcDriver.md
PR 10193 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ResidentMirror.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 10249 core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 10359 docs/dev/debt/libSceAgcDriver.md
PR 10442 core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
docs/dev/ENVIRONMENT.md
PR 10443 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/ENVIRONMENT.md
PR 10743 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/debt/libSceAgcDriver.md
PR 11435 docs/dev/ENVIRONMENT.md
PR 11436 docs/dev/ENVIRONMENT.md
PR 11444 core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 11551 docs/dev/debt/libSceAgcDriver.md
PR 11825 docs/dev/debt/libSceAgcDriver.md
PR 12157 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 12324 docs/dev/ENVIRONMENT.md
PR 12746 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/ENVIRONMENT.md
PR 12849 docs/dev/ENVIRONMENT.md
PR 12944 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 13148 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ResidentMirror.cpp
PR 13251 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 13796 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 13920 core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ResidentMirror.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 13928 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ResidentMirror.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 13929 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ResidentMirror.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 13963 docs/dev/debt/libSceAgcDriver.md
PR 14262 docs/dev/ENVIRONMENT.md
PR 14944 docs/dev/debt/libSceAgcDriver.md
PR 15136 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/debt/libSceAgcDriver.md
PR 15296 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/ResidentMirror.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ResidentMirror.cpp
core/libs/prx/libSceAgcDriver/tests/execution/ResidentHeapMirror.cpp
PR 15529 docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 15548 core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 15570 core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
docs/dev/ENVIRONMENT.md
PR 15621 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/debt/libSceAgcDriver.md
PR 15845 docs/dev/debt/libSceAgcDriver.md
PR 16260 docs/dev/debt/libSceAgcDriver.md
PR 16793 docs/dev/ENVIRONMENT.md
PR 16831 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/ENVIRONMENT.md
PR 17347 docs/dev/ENVIRONMENT.md
PR 17611 core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 17719 docs/dev/ENVIRONMENT.md
PR 17729 docs/dev/ENVIRONMENT.md
PR 17749 docs/dev/ENVIRONMENT.md
PR 17915 docs/dev/debt/libSceAgcDriver.md
PR 17956 docs/dev/debt/libSceAgcDriver.md
PR 18173 core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ResidentMirror.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/ENVIRONMENT.md
PR 18226 docs/dev/ENVIRONMENT.md
PR 19445 docs/dev/ENVIRONMENT.md
PR 20041 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/ENVIRONMENT.md
PR 20187 docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 20315 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/ENVIRONMENT.md
PR 20519 core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
docs/dev/ENVIRONMENT.md
PR 21708 docs/dev/ENVIRONMENT.md
PR 22190 core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ResidentMirror.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/ENVIRONMENT.md
PR 22359 docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 22424 core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
docs/dev/ENVIRONMENT.md
PR 22692 docs/dev/ENVIRONMENT.md
PR 23229 core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
docs/dev/ENVIRONMENT.md
PR 23242 docs/dev/ENVIRONMENT.md
PR 23243 docs/dev/ENVIRONMENT.md

@EagleBearerYS

Copy link
Copy Markdown
Contributor

On the order with #12840 (BDA stores into writable heap mirrors), which conflicts with this PR in GuestBufferMemory.cpp, where both add one call to UploadFinish before takeHeapReferences(): this PR can go first, and #12840 resolves the conflict after it, keeping both sides.

The merge calls #12840's addAddressStoreSpans() before this PR's publishIntoMirrors(). addAddressStoreSpans() adds the spans a draw may store into through an address to writes, and WritesOverlap checks all of writes. So a writable mirror that such a draw may store into takes this PR's Written fallback and flushes the pending images to guest memory, as it does for a declared write, instead of being published into. #12840 then runs its BDA store tests with this PR's agc_driver_resident_heap_mirror and agc_driver_resident_heap_mirror_no_publish on the merged tree.

#12840's checklist will say Depends on: #17796 (merge order only).

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 9, 2026
…images

Add a draw-based case to the resident heap mirror tests: an image store
deferred into a heap mirror, then a draw that retakes the cached address
space (the reuse path). The draw must read the stored value, and the
reuse counter must advance by exactly one per draw.

Requested in review of the publish-into-mirrors change.
@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.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Hi @ashwin280802, I pushed two commits to your branch so this can go into a merge batch, without changing your source:

  • 11a901f47b adds a draw-based test to tests/execution/ResidentHeapMirror.cpp that runs a reused build and checks that the published mirror drains before it is read. With the reuse drain skipped, the test fails (read colour 0, expected 64), so it guards the path this PR changes.
  • 2f8df6fd66 merges current main. The only conflict was in the same test file: it keeps main's new StorageImageZeroStoreTests and your rewritten StorageImageTests, and both are called. All agc driver tests pass on the merged tree on Linux.

Nothing for you to do; if you push to the branch, pull first.

@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Nov 10, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

Hi @ashwin280802, we merged current main into your branch again so it can merge (de3da06). The only conflict was in Graphics/include/Texture.hpp, where main added a storesWhole() declaration in the same spot as your mirror-publish memo members: we kept both. Main also brought back StorageImageZeroStoreTests in ResidentHeapMirror.cpp; it runs after your StorageImageTests cases, as before. Your code is unchanged; nothing for you to do. If you push to the branch, please pull first. Thanks!

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 11, 2026
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 13, 2026
…er input mirror

Recorder: main added CommandClass::InputMirror in the slot this change used for MirrorPublish. MirrorPublish now follows it, with its entry in CommandClassNames, BarrierScopes and BarrierMergedScopes.
GuestBufferMemory: main's profile line (growth rebuilds) followed by this change's mirror publish line.
ENVIRONMENT.md: both rows kept.
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 15, 2026
@klosixgaming-arch

Copy link
Copy Markdown
Contributor

Tested on Cyberpunk 2077 (PPSA03974) 02.120.000, the intro movie at 3200x1800, Windows 11 (10.0.26200), RTX 5090 (NVIDIA 617.42), Ryzen 9 9950X3D, WinLibs GCC 15.2 Release. Base: current main e04bd77e7f + #19071 (736364e8d5), which this title needs to run the intro at full speed. This PR's head 2b2bf36bea is merged on top (dee563ae47, clean merge). One boot each, presents per 10 s from the 10 s summary windows; the median is over the windows after the first two (loading).

build windows median
base, boot before 126 129 114 107 118 123 122 115 123 122
this PR 115 106 115 103 92 106 96 110 117 106
base, boot after 95 117 101 86 122 114 122 133 129 117

About 11% below the boots around it. Single boot; I'll repeat it next session and post the result here. CP77 on Windows has no resident heap mirrors as far as I know, so if this holds it would come from the path itself rather than from publishes. No errors or aborts.

@klosixgaming-arch

Copy link
Copy Markdown
Contributor

The repeat I promised, on Linux this time: no measurable difference here. The PR runs the Cyberpunk intro within 0.5 % of the boots around it, well inside the spread between boots.

Setup: Ubuntu 26.04.1 (Linux 7.0.0-43), NVIDIA GeForce RTX 2080 Ti (595.99.02), Xeon E5-2699 v3, GCC 15.2.0 Release. Base: main e4caa07950 (it includes #19071 now). This PR's head 2b2bf36bea merged on top (3e6fa79556, clean merge), built in a separate tree. Cyberpunk 2077 PPSA03974 02.120.000, intro movie, no input, warm shader caches. Boots alternate base and PR, three each; each number is the mean of the eleven 10 s summary windows from 40 s to 160 s.

boot build presents per 10 s, windows 40 s to 160 s mean
1 base 53 51 52 53 50 51 52 51 51 51 51 51.5
2 this PR 50 49 51 51 49 50 49 49 51 51 51 50.1
3 base 53 51 50 51 50 51 51 50 50 50 51 50.7
4 this PR 53 52 53 54 49 52 50 48 51 50 51 51.2
5 base 52 51 52 52 50 51 51 50 51 50 51 51.0
6 this PR 52 52 53 52 50 50 50 50 51 51 51 51.1
  • Base 51.1 on average (50.7 to 51.5), this PR 50.8 (50.1 to 51.2): −0.5 %, which is noise at this spread.
  • So the −11 % from my single Windows boot doesn't reproduce on this machine. This machine is much slower per frame (about 51 presents per 10 s against 108 to 130 on the RTX 5090), so it may be bound elsewhere; I can't rule the Windows result in or out from here.
  • No driver failure, abort or NotImplemented line in any of the six boots.

@github-actions github-actions Bot removed the perf numbers missing perf pull request without a before and after summary line label Nov 16, 2026

@MarcZX10 MarcZX10 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.

Reviewed — no blocking findings

Nothing blocks this change; the inspected code supports the described resident mirror publication flow, with some edge cases explicitly left unverified.

What I ran

Reviewed head 38ecc79651f123a77d602bce24c2d53f2b803570 using the prepared diff and repo_read.py. No tests or builds were run; the test results in the PR description are author reported.

Results

Check Result Note
Patch and targeted source review passed Main defer and publish paths inspected
Tests and build not run Author reports test runs
Console and other GPUs not run Not verified by this review

Findings

Blocking

None.

Non-blocking

  • The PR description identifies untested paths for reused-build publish drains and mirror eviction during the same build, plus array layers, multiple mips, edge blocks, and memo eviction. Add targeted coverage for these cases as the implementation is extended.

Sources

Reviewed GuestBufferMemory.cpp, Texture.cpp, ResidentMirror.cpp, Recorder.cpp, and ResidentHeapMirror.cpp at the pinned head, alongside the prepared diff. The diff adds fallback checks for read traps, DCC state, drawn rectangles, write-watch coverage, pending generations, and writable mirror writes; it also guards publication with mirror serials and refreshes guest changes before recording GPU copies.

Not verified

No build or tests were run. The PR description’s reported test and performance results were not independently verified. Console behavior, other GPU vendors, and the listed untested edge cases were not verified. Full source text for GuestBufferMemory.cpp and Texture.cpp was excluded from the review bundle; targeted ranges were read through repo_read.py. All changed files listed in the manifest were identified, but not every changed file was read in full. Other changed files not listed above were not reviewed in detail.

To get this to a good state

Nothing is required. Optional: add coverage for the untested paths listed in the PR description.

@domx4q

domx4q commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Validation-layer run of this PR on an NVIDIA GPU under Linux, since CI covers only lavapipe.

Setup: Arch Linux (kernel 7.3.4), GCC 16.2.1, Release, -DBUILD_TESTING=ON; NVIDIA GeForce RTX 4090 (vendor 0x10de, device 0x2684), proprietary driver 620.70.06, Vulkan 1.4.357 (loader 1.4.363), Khronos validation layer 1.4.363.1. Head 38ecc79651 merged onto main e4caa07950 (clean merge); main is the same commit built separately. Every test log reports Selected GPU name=NVIDIA GeForce RTX 4090.

ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer \
  ctest --test-dir build -R '^agc_driver_(resident_heap_mirror|address_draw_space_reuse)' -V
main e4caa07950 this PR
Result 8/8 pass 9/9 pass
Insert instance layer "VK_LAYER_KHRONOS_validation" 8 9
was not found but was requested by env var VK_INSTANCE_LAYERS 0 0
VUID- 0 0

The pattern is the one from the Tested section. agc_driver_resident_heap_mirror_no_publish is added by this PR and does not exist on main, which explains 8 against 9 tests; the 8 shared tests pass on both, and no test is skipped.

The branch is based on 3894f2e184, newer than e4caa07950, so the merged tree also carries the main commits between the two (40 files under core/shader and libSceAgc*); the comparison is therefore e4caa07950 against e4caa07950 + those commits + this PR.

No new VUID- errors; all 9 focused tests pass on Ada.

AI-assisted: yes (Claude Code)

@Scramblrrrr

Scramblrrrr commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Starting a Windows 007 cross-test of your existing implementation, not a competing PR. Public source-only branch: codex/007-pending-mirror-publication-nov18, head ec04f8f0a4a74066f1c05625812abe9c9813fce0, on our pinned 007 diagnostic head b27d32938868605539802d771cb9a2683a120d1f. Your production commit 5b34e43c981d and Dean's reused-build test 11a901f47b retain their authorship and cherry-pick references. This source is building; no Windows native, title or speed result yet.

This integration carries #9508 and the #15295/#12827/#15296 prototype, whose existing unchanged-byte redundant-upload assertion still fails. I have preserved that assertion and its failure status, the partial/concurrent CPU-write checks, zero-store test, transfer-wave limits and the removal of slab host copies. The only substantive adaptation to your upload-generation contract records each touched block's serial at its actual GPU copy/fill recording point, since this prototype reads guest memory into transient staging instead of retaining Slot::host. No CPU slab copies were reintroduced. Recorder timing keeps both InputMirror and MirrorPublish; current declarations and environment entries remain. Conventions pass with only an inherited unrelated debt-length warning.

One caller distinction I am checking before extending anything: 007's latest guarded load has one address-based build versus 946,670 per-resource sparse mirror bindings. publishing is scoped by AcquireRegistered/RetakeSpace, whereas UploadFinish's bindSparseMirror refresh can also reach syncHeapRange. I will first qualify the canonical behavior and its existing regression, then use a synthetic caller-specific check before considering an additional publication scope there. No effect on 007 is assumed from the source alone. Current loading/memory details are on the shared bring-up checkpoint.

Windows 11 26200, RTX 5070 Ti/NVIDIA 617.42, GCC 15.2 r7 Release, Vulkan headers 1.4.340, Khronos layer 1.4.363, SPIRV-Tools OFF. Raw title code, logs, captures and traces stay local. AI-assisted.

Windows follow-up: the original integration ec04f8f0a4 builds, reaches all subsequent unmodified resident data checks while preserving the one original redundant-upload assertion/failing exit, and your publication-disabled control fails at the intended assertion. Actual RTX 5070 Ti, real Khronos insertion, zero VUID/SYNC identifiers.

The additional sparse-caller gap is now reproduced and fixed in the same public branch, head aa114ee081c261b74cb10f549ac27cd77b32c057:

  • Test-only 8c5bf07cee30398fb3f59b2add56c1d9c7971815 creates an 8 MiB registered heap with only 2 MiB committed, reads it through a bounded descriptor (not a BDA pointer), writes a pending storage image, and reads again. It requires the sparse-binding counter to advance and the GPU to receive the image. Your canonical provider passes those data checks, then fails specifically because the image reached guest memory instead of being published into the mirror.
  • Production aa114ee081c261b74cb10f549ac27cd77b32c057 adds six lines: an exception-safe publishing scope inside bindSparseMirror, restoring the previous pointer on exit. It uses your existing deferral, publish, memo, fallback and drain implementation; no second mechanism or weakened guard.
  • Byte-identical fixture and every support/provider except libSceAgcDriver.prx frozen from the negative arm: sparse-caller test passes 3/3 classic + 3/3 actual GPU-heap, each selecting RTX 5070 Ti with a real Khronos device. The heap arm confirms Vulkan descriptor heap: GPU-mode draws and dispatches bind from VK_EXT_descriptor_heap. Zero skips, missing-layer messages or VUID/SYNC identifiers. Checks include published GPU data, unchanged reuse, later CPU read and a CPU store taking precedence over the image.
  • Disabling publication on the fixed provider fails the same specific new regression, as intended. The broader resident data checks complete three more times, with the original redundant-upload assertion and failing exit still preserved. Those full-fixture runs are not counted as passes.

Conventions pass (only the inherited #22072 debt-length warning); no game/FPS result yet. I am preparing a clean child on your exact branch so you can take the small caller fix and its regression without the 007 memory prototype, and will cross-test 007 separately. Raw title data stays local.

Clean follow-up is now public: codex/sparse-descriptor-mirror-publication, head 2cc3f2f27ca2676e8b103c1bc18585bd9a351e1b, directly on your exact 38ecc79651f123a77d602bce24c2d53f2b803570. The test-only commit is 4e4e61521b; the identical six-line production scope is 2cc3f2f27c. Three files, 87 insertions / 7 deletions, no 007 memory-series or heap-integration patches. Your complete original fixture remains the default. The new --sparse-publish-only case is registered separately and explicitly skips unsupported sparse hardware. This clean child passes conventions, but is source-only so far; the real-GPU results above belong to the pinned integration aa114ee081c2, not an unbuilt clean branch.

Further matched regression gate on the integration: the same ten address-space reuse cases (including heap/stages/transitions) pass three rounds on the canonical provider and three on the sparse-scope provider: 30/30 each, ten actual Khronos insertions per round, no skips, missing layer or VUID/SYNC identifiers. Same fixture and supports; only the graphics provider changes. Packaging relinked the provider, so that exact new artifact was checked again for classic and actual-heap sparse publication and later resident data completion. The original redundant-upload failure remains separate.

The guarded 007 run is now active on the packaged integration, same executable and other 417 module hashes, original safeguards and 2048 MiB texture cap. It has rendered the title prompt; there is no gameplay, memory improvement or FPS result yet. No concurrent builds, native GPU tests or replay. Its text-log capture is empty so far, so absence of logged faults is not a success claim. A read-only check of 184 bytes of this hash-verified renderer's own publication counters will establish whether the path is actually used; no title memory or pointers are read.

007 title trial complete: rendered title/offline menu, Resume accepted, then the unchanged free-RAM guard stopped it after 835.013 s total / 86.467 s after queueing Resume. Peak sampled private commitment 29.342 GB, minimum free RAM 1.917 GB, four bounded trims. The text log became available after exit (5.31 MB), with no fatal/unhandled report; the earlier empty-live-log limitation is now resolved for this completed run.

All own-publication counter samples remain zero, last at 12:51:11.775 UTC, about 7.44 s before guard exit. Final mirror summary has 1,088,025 sparse bindings, one address-based build, 1112 heap mirrors / 4308.4 MiB. Thus this run does not demonstrate #17796 or the added scope helping 007, despite the synthetic red/green proof. No gameplay, memory reduction or FPS gain claimed. I am preserving the generic six-line fix and clean regression for your review, and moving the title investigation to existing #15297's overlapping joined-mirror work rather than growing this patch speculatively. All guards and title-data privacy remain.

@rafaconvaitis

Copy link
Copy Markdown
Contributor

Windows + AMD run; I found no AMD run in the description or in the comments. Head 38ecc79651 merged alone onto main 9a50e1014e with git merge --no-ff (clean merge).

Setup: Windows 11 25H2 (build 26200), AMD Radeon 760M integrated graphics (1002:15bf, Vulkan device name Radeon 5), AMD Software 26.11.2 (driver 32.0.32029.2010, Vulkan 1.4.359), selected with ANYPS5_GPU=Radeon, WinLibs GCC 15.2.0 r7 UCRT, Release, BUILD_TESTING=ON, Khronos validation layer 1.4.363 (LunarG SDK 1.4.363.1). Only the focused test targets were built; the other execution tests were left out with ANYPS5_AGC_EXECUTION_TESTS.

ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer, ctest -R '^(agc_driver_resident_heap_mirror|agc_driver_resident_heap_mirror_no_publish)$' -V -j 1, 3 runs per side.

test main this PR
agc_driver_resident_heap_mirror passes 3/3 passes 3/3
agc_driver_resident_heap_mirror_no_publish not in main passes 3/3
  • No negative control: the tests of this PR do not build on main's sources, because they use code the PR adds.
  • VUID- lines: 0 in the main and PR logs. Every run logs Selected GPU name=Radeon 5 vendor=0x1002 device=0x15bf and Insert instance layer "VK_LAYER_KHRONOS_validation", and none logs was not found but was requested.

AI-assisted: yes (build and runs scripted with an AI assistant, on the hardware above).

@oneandonlydean
oneandonlydean merged commit 91bb812 into boykopovar:main Nov 19, 2026
14 checks passed
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.

8 participants