perf(agc): reuse address-based draw builds whose inputs are unchanged #6636
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6636"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-16T00:18:42Z.
What
A draw whose shaders reach guest memory through the BDA table (an address-based draw) builds its resources again on every draw: the lease of the registered memory, the upload, the page table and its fault buffer, the descriptor set and the image lookups. #2657 left such draws out of the resource cache because their build could not be kept: its completion checked the faults, marked the pages the shader stored to, wrote the written ranges back and released the lease, once per build.
In Resident Evil Village (PPSA01556) at the menu, most of queue 0's draws are address-based builds (
APS5_PROFILE_DRAW=1,[draws]lines per 10 s):main6ea62f9b40, with the fixes it needs to reach the menu: 218 of 224 draws, at 29.8 ms each (BDA 29829 (218));mainplus open PRs: 867 of 1,392 draws, at 3.8 ms each (BDA 3821 (867)).The fix. A draw build over the cached address space (#5542) is now kept and reused by a later draw with the same content key, when everything it rests on can be proved again cheaply:
A reused draw takes the space again and refreshes its mirrors as a build does, and its imports are checked once more after the image proofs. Each draw keeps its own completion: its batch holds the space until then, and the completion checks the faults and marks the written pages and the written ranges served in place. Between draws the build pins no guest allocation, so a guest unmap never waits for the resource cache.
Buffers whose descriptor reaches past their allocation (
bae2cd48ec). The two reuse checks of read-only buffers,MovedReadOnlyBuffersandCheckBufferAliases, took each guest buffer descriptor's raw size. A build binds less: past the device's range limit it cuts the size at the registered end, and it trims a stride overhang past the allocation. So a draw with such a descriptor was never reused, and fixing only the moved-buffer check would have made the reused draw fail the alias check. Both checks now use the size the build binds (ShaderResources::GuestBufferBytes, split out ofaddGuestBufferwithout changing what it binds). #7044 (AlxcBTW, merged) addedguestBufferBytesfor the same size, for its moved compute dispatches. Since the merge ofmain55f82fee83that size has one body: main's, inGuestBufferBytes, whichguestBufferBytesforwards to, so builds, both reuse checks and #7044's dispatch check size a buffer the same way. Templates of non-address draws use the same checks, so they get the same fix. This was found by an after-the-fact completeness review, not by a title.Review follow-ups. The same review found three more gaps, each fixed with its test:
BeginUsenow returns a token that releases the use when it is destroyed: at the end of the completion as before, or when the batch is discarded.SameSnapshotsand built again. Both paths now sort them by address, then size.Recorded GPU writes over a snapshot (
6e5b5bdf4b). The reuse proof compared a draw's snapshots with memory right after its in-use check. A write recorded earlier in the batch over a snapshot's range (a fill, a copy, a dispatch storing through a descriptor) that hadn't run yet left memory holding the bytes the capture saw, so the proof passed and the reused draw ran after the write on a program specialized on the old bytes. A draw that builds anew syncs through such writes in the decoder's own validation. The proof now first completes the recorded writes over each snapshot's range (CompleteSnapshotWrites), so such a capture is refused and the draw builds again. Stores through the BDA table aren't recorded as pending writes; a later use reads them in place. This was found by a later review, not by a title.Profile counters. With
APS5_PROFILE_DRAW=1, a[rescache] address-based draws:line follows the[rescache] draws:line every 10 s, in windows that had an address-based proof or an in-use refusal. It gives the proofs, the reuses, the refusals by reason (in use, not reusable, snapshots, the space and why, images or buffers, imports, a proof that threw, moved buffers), the time spent in refused proofs, the host import refusals (budget and held import, and how many came while a reused draw held its space), and the pin-contention waits. The counts are relaxed atomics, and without the profile nothing prints. The use token also carries whether its use was a reuse, so a discarded batch releases that count too. From the test:What it leaves out (also in the debt file):
APS5_NO_ADDRESS_DRAW_REUSE=1builds every one as before.With the draw pipeline (#1202, on by default). A pipelined direct draw is recorded by the committer in
commitDraw, and any other draw inline afterlockForDraw; both hold the GPU lock throughGraphics::Draw, where the cache lookup, the proofs andBeginUserun. Completions run under the hold that reaps or syncs their batch. So the build's use count and its fault verdict change only under that lock, and pipelining opens no reuse race.The commits:
refactor(agc): split the cached address space checks out ofAcquireRegistered(spaceMiss,stampSpaceImports,refreshSparseMirrors,appendWritableMirrors), so a reuse makes the same proof and refresh as a build. No behaviour change.perf(agc): the reuse, with its tests.docs(agc): the debt entry.fix(agc): buffers whose descriptor reaches past their allocation (above).fix(agc): refuse address-based reuse after rejections or a throw.main5d9dcc42d2, which brings #5837's discarding of failed batches.fix(agc): release a draw build's use when its batch is discarded.fix(agc): order a draw's snapshots the same on decode misses and hits.perf(agc): count address-based draw reuses and refusals in the draw profile.fix(agc): complete recorded GPU writes over snapshots before an address reuse proof (above).main55f82fee83, which brings #7044; itsguestBufferBytesand this PR'sGuestBufferBytesnow share one body (above).main2626e5ee7e, which brings #7339's host import construction guard.WaitForLeasesAndImportstakesmain's signature, withoutnoexcept, and this PR'sliveSnapshotComparedstays beside it.main0d078f75d3, which brings #7089's masking of reserved bit 30 in guest buffer descriptors.GuestBufferByteskeeps this PR's signature and takesmain's mask.docs(environment): theAPS5_NO_ADDRESS_DRAW_REUSErow indocs/dev/ENVIRONMENT.md, which lists every switch since #6078.main6efb7261b5, which brings #6492's debt entry next to this PR's; both are kept.main6696def6e6, which brings #7650's multisample target guards for cached images and #6646's mirror check.importAllocationtakesmain's step-down andpinnedBytes, and counts a refusal only where the import is refused. A cached space is reused only when each of its heap and sparse mirrors is still watched or can't be imported now, both when it is acquired and inResumeSpace, and its imports are stamped once per space, asmaindoes.test(agc): reused draw builds over a sampled image whose memory became a multisampled target, with watched imports and without the address table (below).Cost. A reuse makes the proofs above in place of a build. Synthetic draw on lavapipe (200 draws, median of 3): with each draw waited for, the per-draw time drops 57%, 50% and 48% at 512, 6,600 and 10,800 registered ranges (74.3 to 32.2, 197.2 to 99.2, 283.5 to 148.3 us). Back to back, a draw's build is still in flight when the next draw repeats it, so nothing is reused, and the time is within 3% of
main's. Resident Evil Village's pair, with and withoutAPS5_NO_ADDRESS_DRAW_REUSE=1, follows in a comment.Overlap. Conflicts with open PRs are in shared lines, resolved by keeping both sides:
ShaderResources.cpp. Merged together, that condition must also keep an address-based build from being reused.Draw.cpp, where its prepared content key and this PR's in-use check combine.BdaResourcestable it was built with, and #6628 makes that table depend on its multisample guard generation, which none of this PR's space checks read. Whichever merges second hasBdaResourceskeep the guard generation its table was built or found under and exposeTableCurrent(), and has the address-based reuse proof refuse a hit when it returns false, with a test that adds and then clears a guard around a cached address-based draw.main6696def6e6: a cached space is reused only when each of its heap and sparse mirrors is still watched or can't be imported now, both whenAcquireRegisteredfinds it current and inResumeSpace. A mirror whose import is refused doesn't count against the space: its existing refreshes bring that mirror up to date in full.UploadFinish, which a reused build never runs: it takes its space back throughResumeSpaceand proves itself inRevalidate. Whichever merges second publishes the space's unit shadows afterproveBuildinRevalidate(aPublishSpaceShadows()call), with a test that reuses a draw over a shadowed heap.Tested
agc_driver_address_draw_reuse(tests/execution/AddressDrawReuse.cpp, lavapipe):agc_driver_graphics(tests/BdaResources.cpp) additions:SpaceRegions,DirectWrites,SameSnapshots, suspending and resuming the space.agc_driver_address_draw_reuse'sOversizedVertexBuffercase (bae2cd48ec) has a vertex buffer descriptor of 64 GiB over a 64 KiB allocation. The draw is drawn, waited for and drawn again, and both draws must store through the BDA table, with the second reusing the first one's build. On GitHub's runners (run), withShaderResources.cppandDraw.cppreverted to ec17620356's, it fails in all 3 runs on Linux ("a draw whose vertex buffer descriptor reaches past its allocation built its resources again"). With them, it andagc_driver_graphicspass 10 runs in a row. On Windows the draw test skips without a Vulkan device andagc_driver_graphicspasses.main44df216321(only the new test applied):agc_driver_address_draw_reusefails on Linux (run 38795295627); Windows skips it without a Vulkan device.agc_driver_address_draw_reuse,agc_driver_address_space_teardown,agc_sparse_buffer_holes,agc_compute_descriptor_layout_flags,agc_descriptor_pool_reset_failureand the three alpha-to-coverage and centroid state tests): all pass on Linux and Windows (run); Windows skips the lavapipe one. The libc and libkernel suites pass apart from libc'sprecise_waiton Linux (a timing test; it passed in the red run) and libkernel'sguest_kqueueon Windows, which fails onmainon that runner too.^agcsweeps at the head:main's code:agc_driver_mesh_index_cacheaborts inside llvmpipe's LLVM ("Cannot emit physreg copy instruction"), also withmain's code (run). #6560 now skips it on llvmpipe.agc_driver_preparation_scope_settlefails only under the sweep's parallel load and passes alone.agc_driver_pm4_replay_tool(0xc0000139), also fails onmainon that runner.maindoesn't build in full with MinGW since #5747 (alignas(65536)in a test), so this sweep ran with #6452's fix for that test applied, for this check only.main44df216321; it now mergesmain5d9dcc42d2.agc_driver_graphics'saddressRejectedTableElementTests: an address-based draw whose one image-table element points at reserved pages, which the build rejects as unmapped; the pages are then committed with no registry change. Red: "an address-based draw build whose image table element was rejected as unmapped was reused after the element's surface was committed".agc_driver_address_draw_reuse'sThrowingProof: after the build, the sampled image's memory becomes a 4x multisampled color target, so the reuse proof's texture lookup throws. Red, with rejections blocked but no catch: "the reuse proof of an address-based draw build whose sampled image's memory became a multisampled target threw instead of refusing the reuse".agc_driver_graphics'saddressFailedSubmissionTests: a build whose batch fails to submit (the mock returnsVK_ERROR_OUT_OF_HOST_MEMORY) must not stay in use. Red: "an address-based draw build stayed in use after the batch that took it failed to submit".agc_driver_address_draw_reuse'sDecodeCacheHit: a decode miss, a second miss and a decode-cache hit of the same submitted draw build once. Red: "a submitted draw that hit the decode cache built its resources again after a decode miss of the same draw".^agcpasses 607 of 607 (43 skipped), and each commit builds and passes its own tests.guest_kqueue, which fails onmainon that runner too.agc_driver_address_draw_reuse'sReuseCounters: four waited draws count 4 proofs and 4 reuses; two draws back to back count one reuse and one "in use" refusal; a rewrite of the pixel program's bytes counts one "snapshots" refusal.GuestWrite,FaultandThrowingProofcheck their counts too, and the reused case ofaddressFailedSubmissionTestschecks that a reused use's hold is released when its batch fails to submit.^agcpasses 607 of 607 (43 skipped).agc_driver_address_draw_reuseandagc_driver_graphicswith the tests run alongside pass 10 runs in a row on Linux and Windows (the new tests need the counters' API, so they don't build on the previous head). The suites' only failures were libc'sprecise_waiton Linux, a timing test, and libkernel'sguest_kqueueon Windows, which fails onmainthere too.6e5b5bdf4b), Linux (lavapipe), CI configuration:agc_driver_address_draw_reuse'sPendingSnapshotWriterecords aFillBufferthat rewrites the pointer the pixel shader loads and, in the same GPU-lock scope, offers the same draw with its old capture. It must read the new value, count one more snapshots refusal and no reuse, and build once more. Red without the sync: "a draw whose captured snapshot a pending GPU write changed was not refused for a changed snapshot and rebuilt (1 reuses, 0 builds)". With it the test passes 20 runs in a row, and^agcpasses 607 of 607 (43 skipped; a first sweep's one failure wasagc_driver_preparation_scope_settleunder the sweep's parallel load, which passes 5 of 5 alone). On GitHub's runners (run) the new case fails 2 of 2 runs on Linux at the previous head, and with the sync it and the tests tied to the file pass 10 runs in a row. On Windows (run, with #6452's MinGW fix for an unrelated test applied for this check only),agc_driver_graphics,agc_driver_address_space_teardownandagc_sparse_buffer_holespass 10 runs and the draw test skips without a Vulkan device. The^agcsweeps' only failures areagc_driver_preparation_scope_settleon Linux (and, in the first run,agc_frame_dump_io's pipe flake, whichmainhas since fixed in4b8ccd2e42) andagc_driver_pm4_replay_tool(0xc0000139) on Windows, as before.fc9c5416fc), after jotitadev's macOS run (review), whereThrowingProoffailed with imports watched. The head that run tested,28433ba132, predates #7650, which refuses that case inproveBuild(RequireNoMultisampleColorTarget) before either proof runs; the merge of6696def6e6brings it. Linux (lavapipe), CI's configuration:agc_driver_address_draw_reuse_watched_imports: the same test withAPS5_WRITE_WATCH_IMPORTS=watch, registered on Linux and macOS builds.ThrowingProofalso checks a cached build without the address table.agc_driver_address_draw_reuseat the non-address case ("a draw build without the address table whose sampled image's memory became a multisampled target was reused"). With it, each passes 20 runs in a row.^agcpasses 792 of 793 (57 skipped). The one failure,agc_driver_sgpr_pattern_fill_keys, fails under the sweep's parallel load onmaintoo.precise_waiton Linux, a timing test.main6696def6e6(084de35d85), on GitHub's runners (run): the reuse tests and the tests tied to the merged files pass 5 runs in a row on Linux and Windows (Windows skips the lavapipe ones), and the libc and libkernel suites pass.main0d078f75d3and6efb7261b5(ff5fe23f8b, then the row4bacab407a, thenca05f74aec, the head), on GitHub's runners: at4bacab407athe^agctests pass 3 runs in a row on Linux (710, 0 failed), and the libc and libkernel suites pass (run); atca05f74aecthey pass again on Linux (710, 0 failed), as do the suites (run). On Windows the only failures at both areagc_driver_pm4_replay_toolandagc_shader_replay_tool, as in the runs below, and the suites pass.main2626e5ee7e(3db18a2b1c), on GitHub's runners (run): the^agctests (705, 0 failed), with the reuse tests and #7339'sagc_driver_host_import_lifetimeandagc_driver_host_import_mutation_race, pass 3 runs in a row on Linux, and the libc and libkernel suites pass. On Windows the only failures areagc_driver_pm4_replay_toolandagc_shader_replay_tool, as in the run below.main55f82fee83(b5d0a2a039), on GitHub's runners (run): the reuse tests and the 14 tests tied to the changed files pass 3 runs in a row on Linux, as do the^agctests (682, 0 failed), and the libc and libkernel suites pass. On Windows the only failures areagc_driver_pm4_replay_toolandagc_shader_replay_tool, which fail the same way on that runner for an unrelated branch (run).[draws]lines above.APS5_TRACE_SECONDS=60:30). The base ismain84b0d2f24with #6557, #6727 and #6762, 6 runs (3 before and 3 after this PR's); this PR is merged on top of it, 3 runs (comment):Frame p50: 77.9 to 84.5 ms on the base (mean 82.0); 78.7, 85.6 and 87.6 ms with this PR (mean 84.0). Base p90: 84.3 to 93.6 ms; p90 with this PR wasn't given.
No gain in this scene. simonbronk reads it as no measurable change and notes that the menu may not reach the path this PR speeds up.
simonbronk's summary lines for his first pair, the first base run (
base-r1) and the first run with this PR (pr6636-r1), from his comment. The runs and traces are his:That pair's frame p50 is 84.5 ms without this PR and 78.7 ms with it, but as simonbronk says, it isn't representative: his other runs overlap, so the pair doesn't show a reliable gain. Thanks to simonbronk for the runs and the lines.
python3 tools/check_conventions.py --base origin/main: passed.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T00:26:48Z.
Code review location:
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp; line 2828Integration question for #6628: this reuse path appears to preserve the
BdaResourcesobject created with the originalShaderResourcesbuild.ShaderResourcesconstructsbdaonce (ShaderResources.cpp:1918), while thisRevalidateresumes/proves the address space but does not recreate the BDA page table. The #6628 fix filters native-MSAA spans whenBdaResourcesis built and keys that table to the MSAA guard generation. If a reusable address-based draw is built before a native MSAA guard is added, could a later cache hit retain the old table with that guarded span? It may need to record/check the guard generation during reuse (and rebuild/reject on change), with a test that adds/removes a guard around a cached draw. I have not tested this integration; please correct me if another proof already invalidates the template.Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-16T00:30:12Z.
Code review location:
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp; line 2828Yes, that's a real gap for the two together, and you've read the reuse path right.
Revalidateresumes the space and proves the images and imports, but it keeps theBdaResourcestable from the build (ShaderResources.cpp:1918), and nothing on that path reads your guard generation:spaceMisschecks the device, the registry generation and the import epoch, and adding a native MSAA guard changes none of them. Onmainalone the table depends only on the address space, which those checks cover, so the gap only opens once both PRs are in.Neither PR can close it alone, since
MultisampleTargetRangeGeneration()exists only in #6628 and the reuse path only here. Whichever merges second can: record the generation the build's table was made under, and haveRevalidatereturn false, so the draw builds anew, whenMultisampleTargetRangeGeneration()has moved since. The generation also moves when an owner is cleared, so that covers a span coming back too. The test would build a cached address-based draw, add a native MSAA guard over one of its ranges, and require the next draw to rebuild with that span left out, then rebuild again once the owner is cleared. I've added this to the overlap list here, and if this PR merges second I'll add the check and the test to it.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T00:30:33Z.
Code review location:
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp; line 2828Thanks, that confirms the interaction and clarifies ownership. The guard generation needs to be part of the reuse proof when both changes are present, and checking it in whichever PR merges second avoids duplicating the integration in #6628. I have no further question on this path.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T00:44:31Z.
Code review location:
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp; line 2828Thanks for confirming the interaction. #6628 now keys cached tables by
(address-space serial, MSAA guard generation)and filters the table on a cache miss after the guard generation changes. This closes stale reuse insideBdaResources, but I agree the reusable draw template can retain theShaderResourcesobject and bypass that constructor entirely. CouldRevalidatecompare the generation captured by the template againstMultisampleTargetRangeGeneration()and rebuild on mismatch, with the add/remove guard test you described? Since #6628 is still open, this seems the appropriate integration point if the two PRs land in this order.Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-16T00:48:00Z.
Code review location:
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp; line 2828Yes. If #6628 lands first, this PR adds it:
BdaResourceskeeps the guard generation its table was built or found under, and the address-based reuse proof inRevalidaterefuses the hit when that differs fromMultisampleTargetRangeGeneration(), so the draw builds anew. The add-then-clear guard test comes with it. If this PR lands first, the same check fits in #6628, and I can send the code.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-16T00:59:49Z.
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.
main)core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppL488, L625-626core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppL2497-2499core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppL2497, L2502-2503, L2520-2521core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppL493Some 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.
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppdocs/dev/ENVIRONMENT.mdcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppdocs/dev/ENVIRONMENT.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mddocs/dev/ENVIRONMENT.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppdocs/dev/ENVIRONMENT.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/ENVIRONMENT.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/ENVIRONMENT.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/ENVIRONMENT.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/ENVIRONMENT.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/ENVIRONMENT.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mddocs/dev/ENVIRONMENT.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/ENVIRONMENT.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdImported from boykopovar/AnyPS5. Originally posted by johnmaia on 2026-10-16T02:47:59Z.
In-game run of head
ec1762035: Epic Mickey: Rebrushed (PPSA15657, UE 4.27), short runs to the first level withAPS5_PROFILE_DRAW=1. Linux, RX 7600 (RADV, Mesa 25.2.8). Tree:main5d9dcc42d+ #6236 (to get past PlayGo) + this head.No new failures. No driver failure,
Requireor device loss in any of the 14 runs, with or withoutAPS5_NO_ADDRESS_DRAW_REUSE=1.Speed: no measurable difference in this title. It has about 240 address-based draws per 10 s in the level. Means of the last four
[draws]lines of each run that reached the level:BDAus per draw (count)buildus per draw (count)Only one run with reuse off reached the level, so this is one comparison point. Most runs with reuse on sit at 0.8 to 1.1 ms per address-based draw, the same as that run; two runs averaged 4.4 and 10.2 ms. The PR doesn't log how many builds it reuses, so I can't tell how often reuse happens here. A
[address]count of reuses would make that visible.Crash rate at level load. This title has an intermittent crash on
mainwhile it loads the level (UE "Serial size mismatch": a 64 KiB block of file data the title just read is zeroed about 18 ms later, with no CPU write path of the driver involved; about 2 in 5 runs onmain). On this tree:APS5_NO_ADDRESS_DRAW_REUSE=1So reuse doesn't cause it; it makes it rarer. The PR isn't the fix, but this suggests the per-draw build, lease and completion of address-based draws on
mainare involved. I'm following that up separately.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-16T02:51:36Z.
Thanks for the runs and the tables. You're right that nothing counts reuses yet. I'm adding a count of reuses, and of refused reuses by reason, to the draw profile output, which should also show whether the two slow runs (4.4 and 10.2 ms per address-based draw) went into refused proofs. Thanks as well for the crash counts with reuse on and off. I'll post the counts from Resident Evil Village (PPSA01556) here once the commit is in.
Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-16T02:52:21Z.
On the level-load crash: a 64 KiB block zeroed shortly after the title read it matches a known gap listed in
docs/dev/debt/libSceAgcDriver.md. Pending storage-image results are stored when something next reads their memory, not when the GPU work that wrote them completes, so memory a title waits for, frees and reuses can be overwritten by a late store. If a run that crashes still crashes withAPS5_STORE_AT_LABEL=1(orAPS5_STORE_AT_FLIP=1), it's something else; if it stops, it points there.Imported from boykopovar/AnyPS5. Originally posted by johnmaia on 2026-10-16T17:33:32Z.
@EagleBearerYS thanks,
APS5_STORE_AT_FLIP=1stops it. Epic Mickey: Rebrushed (PPSA15657), short runs to the first level, Linux, RX 7600 (RADV, Mesa 25.2.8). Tree:main5d9dcc42d+ #6236 (e088fd874), no other changes.APS5_STORE_AT_FLIP=1The three failures without it:
ObjectSerializationErroronSM_MachineSet_01b, the same mesh as before (the "Serial size mismatch" crash).LowLevelFatalError [Line: 1609]right after the title opens/savedata0/ue4savegame.dpx.sav.Earlier runs of the same tree without the variable failed 2 of 5. With the flag, all 16 runs reached the level and played to the end of the run.
APS5_STORE_AT_LABEL=1couldn't be compared: with it the level load doesn't finish ("GameThread timed out waiting for RenderThread after 120.00 secs", 2 of 2).So it points at the late store in
docs/dev/debt/libSceAgcDriver.md(#1970). One detail that may matter for a fix: in an earlier trace, the crashing pair's APR read landed on a 64 KiB block that had a storage image write-back about 50 ms before. When that read started, its destination was in neither the published pending-write snapshot norRecorder::PendingWriteOverlaps, so a flush on the read path that relies on them would not catch it.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-16T17:39:40Z.
@johnmaia thank you for the alternated runs. 0 of 16 with
APS5_STORE_AT_FLIP=1against 3 of 8 without, on a tree without this PR, puts the Epic Mickey: Rebrushed (PPSA15657) level-load crash onmain's late storage-image store (the debt entry indocs/dev/debt/libSceAgcDriver.md), not on this PR. Your detail that the APR read's destination was in neither the published pending-write snapshot norRecorder::PendingWriteOverlapsmatters for a fix on the read path, and I've passed it on with your numbers. The reuse counter you asked for is in (the[rescache] address-based draws:line, commit 9); the Resident Evil Village (PPSA01556) counts follow when I have a slot on the PC.Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-16T18:26:57Z.
@johnmaia Thanks for the A/B. It pinned this down. A storage image's write-back is recorded on the GPU and can land after a later APR read into the same memory, which zeroes the file data. Host writes into guest memory also didn't wait for GPU writes pending there. A fix is on
EagleBearerYS:fix/agc-host-write-pending-storage(99af947b18, on main66e290f1c0). Could you try it on Epic Mickey: Rebrushed the same way as before: runs withoutAPS5_STORE_AT_FLIP, alternated? If this was their cause, theObjectSerializationErroronSM_MachineSet_01b, theLowLevelFatalError [Line: 1609]after the save opens, and the SIGSEGV should no longer appear. WithAPS5_TRACE_APR=1 APS5_TRACE_FLUSH=1, an APR read over pending results is now followed at once by a[flush] image …line, before the read's bytes land. If a run still fails, the[apr] readline nearest the failure would help.Imported from boykopovar/AnyPS5. Originally posted by parl0v on 2026-10-16T19:52:50Z.
Data point: RTX 3060 12 GB (NVIDIA 617.42), i5-12400F, Windows 10 19045, MinGW GCC Release. Minecraft Dungeons II (PPSA16064 01.100.100), title screen, no input, 200 s rows,
APS5_PROFILE_DRAW=1 APS5_PROFILE_GPU=1;mainc84249186vsmain+ this PR, interleaved with three other PRs in one batch, two rounds. FPS is the mean of the last 10[present]windows, GPU busy and idle gaps per frame over the last 8. This scene is CPU-bound on this machine (45-47 ms of idle gaps per frame).main89ab0ea75)Neutral on this scene (within the row spread); no regression. 0 fatal.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by johnmaia on 2026-10-17T02:47:45Z.
@EagleBearerYS your fix stops it. Epic Mickey: Rebrushed (PPSA15657), short runs to the first level, no
APS5_STORE_AT_FLIP, Linux, RX 7600 (RADV, Mesa 25.2.8).Current
mainno longer reproduces it often enough to measure, so I also ran the fix on yesterday's base, where it fails reliably:main5d9dcc42d+ #623699af947b1,082c3268acherry-picked)maine751dd205maine751dd205+ your branchNone of the three failures appeared with the fix: the
ObjectSerializationErroronSM_MachineSet_01b,LowLevelFatalError [Line: 1609]and the SIGSEGV. All 12 runs reached the level and played to the end of the run.maine751dd205alone also passed 8 of 8, so something merged between5d9dcc42dande751dd205makes the window rarer. I haven't looked into which; #5905 (prewarm mapped dma-buf) changes import timing and is the one I'd suspect.With
APS5_TRACE_APR=1 APS5_TRACE_FLUSH=1on the fixed old base, 23 APR reads were followed at once by a[flush] image … for memory accessover their destination, before the bytes landed. One is the image from the earlier trace:AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-17T02:56:51Z.
@johnmaia Thanks, that settles it. On the base that crashed, 6 of 24 runs failed without the fix (3 of 8, then 3 of 16) and none of 12 with it, and none of the three failures came back.
The two commits you cherry-picked (
99af947b18and082c3268ac) are from #6926, not this PR, so I've added your runs to #6926's description as its Epic Mickey: Rebrushed (PPSA15657) evidence. I left out the current-mainrows' comparison: both trees pass 8 of 8 there, so they can't tell the fix apart.Your trace shows the fix at work. Each
[flush] image … for memory accessright after an[apr] readis #6926's host write hook storing the image's pending results over the read's destination before the file's bytes are written. Without the hook, that store was only recorded, and it landed after the read, which is the zeroed block in your earlier trace.#5905 could well be why current
mainrarely shows it, since it changes when Linux dma-buf imports settle. The fix doesn't depend on that timing: it orders the host write after any store recorded over the same memory.One optional extra: on #6926's current head (
276f67d366),APS5_PROFILE_DRAW=1prints a[hostwrite]line every 10 s with how many host writes waited for GPU work and for how long. That would give the PR its cost in the title. Your runs already answer the crash, so only if it's convenient.Imported from boykopovar/AnyPS5. Originally posted by simonbronk on 2026-10-17T22:08:26Z.
Tested on Onimusha's menu: no measurable change in this scene.
Setup: Onimusha: Way of the Sword (PPSA27836), boot to the language menu with no input,
APS5_TRACE_SECONDS=60:30, warm cache. Windows 11 26200, RTX 5070 (617.42), 3840x2160. Basemain84b0d2f24+ #6557 #6727 #6762 (5c521efea), 6 runs (3 before and 3 after the PR runs). The PR is merged on top of it (clean merge), 3 runs.This scene may simply not exercise the path this PR speeds up. Summary lines and traces available on request. AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-18T19:53:58Z.
@simonbronk a small ask, if you still have them: the Onimusha: Way of the Sword (PPSA27836) runs you did for this PR (
main84b0d2f24with #6557, #6727 and #6762, with and without this PR,APS5_TRACE_SECONDS=60:30) each should have written anaps5-summary.jsonlnext to its trace. Could you paste one line from a run without this PR and one from a run with it? The repo's new perf check reads those lines from the PR, and yours is the cleanest pair this PR has. The traces aren't needed.Imported from boykopovar/AnyPS5. Originally posted by simonbronk on 2026-10-18T21:33:23Z.
Here they are, from the runs in my comment above (same tree, scene and machine, warm cache). The pair: the first base run and the first run with this PR.
Without this PR (
5c521efea=main84b0d2f24+ #6557 #6727 #6762),base-r1:With this PR merged on top (
9f86b47f6),pr6636-r1:That single pair favours the PR (p50 84.5 → 78.7 ms), but it is not representative. The other runs overlap, as in my comment above. All nine lines (6 base, 3 with the PR):
All runs
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-19T00:21:25Z.
This pull request is labeled
perf, so it needs the summary line of a capture onmainand one with the change, from the same title, scene and machine, as the Performance report form asks. Please paste bothaps5-summary.jsonllines, attach the two traces and add the output oftools/trace_digest.py.Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-19T03:22:47Z.
Review: COMMENTED
Apple GPU / MoltenVK run. One failure on macOS:
agc_driver_address_draw_reusefails at theThrowingProofcase, and it comes from how macOS write-tracks host imports.Machine: Apple M2 Max, macOS 27.2, x86-64 build under Rosetta. Head
88b9b7f3c, PR diff applied cleanly. The current head28433ba13only mergesmain; the PR's own diff is unchanged. Drivers: MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0) and MoltenVK main + SPIRV-Cross #2704.Tested: the tree is
maina373e85e5+ mugurc's macOS series (ci/macos-series-2, includes ImportWatched) + the PRs needed to build on macOS (#6667, #6668, #7524, #6969, and two files of #7332), not plainmain(it doesn't build on macOS yet). This PR's base (84c1a4d9a) is an ancestor of thatmain. Base on that tree: 40^agcfailures with MoltenVK 1.4.2 and 26 with MoltenVK main + #2704, the same known failures in every run below unless noted. I also stacked #6639 and #6557 in one build; the failure below is the same with this PR alone.agc_driver_graphics(with the newBdaResources.cppcases),agc_driver_pipeline_journalandagc_pipeline_journalpass 3 of 3 on both drivers.^agcsuite: 41 of 729 on MoltenVK 1.4.2 and 27 of 729 on MoltenVK main + #2704. The base failures plus one,agc_driver_address_draw_reuse, on both drivers, every run: The cases before it in that test pass.What separates it:
agc_driver_address_draw_reusehost imports resolve write protection: no ... imported ranges stay watched)APS5_WRITE_WATCH_IMPORTS=watchAPS5_WRITE_WATCH_IMPORTS=unwatchAPS5_NO_FAST_REVALIDATE=1So with watched imports, the fast proof (
fastRevalidate) finds the image's memory unchanged afterMultisampleTargetViewtakes it over, andRevalidatereturns true. The full walk throws there, and the reuse is counted as a refusal that threw, which is what the test expects. My guess is that a GPU-side change of ownership leaves no write stamp for the fast proof to see when imports stay watched. If so, it would show up on Linux or Windows withAPS5_WRITE_WATCH_IMPORTS=watchas well. I haven't checked that, and I don't know whether a cached non-address draw has the same gap throughfastRevalidate.Without the fix I couldn't run the test, since it uses the reuse API this PR adds.
GPUs tested: Apple M2 Max (MoltenVK 1.4.2; MoltenVK main + SPIRV-Cross #2704)
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T07:27:29Z.
Review: CHANGES_REQUESTED
Thanks for the thorough work and the follow-up fixes. Three things block this one:
maininGuestBufferMemory.hpp(DeviceReadsnext to the newSpaceRegions/SuspendSpace/ResumeSpace/... declarations) andGuestBufferMemory.cpp(host import replacement nearheld(it->second):mainnow usesreplaced += it->second.pinnedByteswhile this branch uses.bytesand addscountImportRefusal). Please rebase and re-run the reuse tests; the import-size change frommainhas to carry into the refusal counters.agc_driver_address_draw_reusefails atThrowingProofwhen imports stay watched (default on that machine, alsoAPS5_WRITE_WATCH_IMPORTS=watch); it passes withAPS5_NO_FAST_REVALIDATE=1orunwatch.fastRevalidateaccepts the draw after the sampled image's memory became a multisampled target, where the full walk throws. Please make the fast proof refuse that case (and check whether a cached non-address draw has the same gap), ideally with a Linux test usingAPS5_WRITE_WATCH_IMPORTS=watchso CI covers it.perflabel: the bot asks for theaps5-summary.jsonllines ofmainand the change from the same title, scene and machine, plus thetools/trace_digest.pyoutput. The Onimusha pair posted doesn't show a gain (the author's own wording), so please attach a pair from a scene that does exercise address-based draws (Resident Evil Village, onmainplus this PR only, not a local tree with other PRs).Welcome back once these are addressed.
Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-21T04:50:54Z.
@adriadam10, thanks for the review. All three points:
Conflicts with
main.084de35d85mergesmain6696def6e6.importAllocationtakesmain's step-down andpinnedBytes, so the replaced size counts pinned bytes, and a refusal is counted only where the import is refused, not where it steps down to a smaller size. A cached space is reused only whenmain's check of its heap and sparse mirrors passes, both when the space is acquired and inResumeSpace, and its imports are stamped once per space, asmaindoes. On GitHub's runners (run) the reuse tests and the tests tied to the merged files pass 5 runs in a row on Linux and Windows (Windows skips the lavapipe ones).The macOS failure. Your and @jotitadev's reading is right. At
28433ba132,fastRevalidatenever looked at the multisample target guards, andMultisampleTargetViewwrites no guest memory, so with watched imports nothing the fast proof compares had changed. #7650 (merged) now refuses that case inproveBuild, throughRequireNoMultisampleColorTarget, before either proof runs, and the merge brings it into this branch. It checks a build's ordinary sampled and storage ranges; image tables stay exempt, as #7650's debt entry says. With that line removed, the case fails on Linux too when imports stay watched (APS5_WRITE_WATCH_IMPORTS=watch).fc9c5416fckeeps it covered on CI:agc_driver_address_draw_reuse_watched_importsregisters the same test again withAPS5_WRITE_WATCH_IMPORTS=watch, on Linux and macOS builds.ThrowingProofalso checks a cached draw build without the address table, the non-address case you asked about. It had the same gap before #7650, in both import modes, and the same guard refuses it now.With #7650's line removed, the new registration fails at the address-based case ("an address-based draw build whose sampled image's memory became a multisampled target was reused") and the existing one at the non-address case ("a draw build without the address table whose sampled image's memory became a multisampled target was reused"). With it, each passes 20 runs in a row on Linux, and on GitHub's runners (run) both pass 5 runs in a row with the tests tied to the changed files. The
^agctests pass 792 of 793 (57 skipped). The one failure,agc_driver_sgpr_pattern_fill_keys, fails under the sweep's parallel load onmaintoo.@jotitadev, could you run
agc_driver_address_draw_reuseagain on macOS withfc9c5416fcmerged into your tree? With the default (watched imports) it should pass now.The perf pair. I'll post a Resident Evil Village (PPSA01556) pair from a scene with address-based draws:
mainagainstmainplus this PR, on the same machine, with bothaps5-summary.jsonllines, the traces and the output oftools/trace_digest.py. It's queued behind getting the title to boot on currentmain, and the post will name anything either tree needs beyondmainand this PR.Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-21T12:42:20Z.
@adriadam10, the Resident Evil Village (PPSA01556) runs show this PR doesn't pay off there, so I'm closing it rather than make you wait for the pair I promised.
What the runs showed. Both ran at the title's menu, with this PR at
fc9c5416fc. They aren't onmainplus this PR only, as you asked:main1ff5c8ac5caborts in Resident Evil Village's intro without #8926's fix. So both trees aremain1ff5c8ac5c+ #8926's fix (63d5414338) + this PR. Both usedAPS5_LAZY_SHADER_PREPARE=1,APS5_NO_GPL=1andAPS5_HOST_IMPORT_MIB=6400on a warm cache.Why. The proof compares the addresses a build read through its address space. Most of those reads are per-draw constants whose address changes from one draw to the next: mesh-stage constants of 0x50 and 0x70 bytes, and 4- and 8-byte pixel-stage reads. Ten draw keys read 9 or more distinct addresses each, and they account for 55% of the address reads the second run logged. Keeping a few builds per key would match about a quarter of those reads at best.
A gain here would need a proof over what the build derives from those reads, not over their addresses. That's a bigger change than this PR.
Thanks to you for the review, to @jotitadev for the macOS run, to @MarcZX10 for the review comments, to @simonbronk for the Onimusha: Way of the Sword (PPSA27836) runs, and to @johnmaia for the Epic Mickey: Rebrushed (PPSA15657) runs.
Pull request closed