feat(agc): support version initialization and raw compute programs #685
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/685"
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 nicolasabosch on 2026-10-05T15:18:30Z.
What
Native homebrew initializes AGC with a single version argument and can submit a raw compute-program address without registering an AGC shader header. The existing
sceAgcInitsignature expects a state pointer, and dispatch rejects an unregistered address.Expose the version-only
sceAgcInitwhile retaining the existing two-argument export under NID23LRUSvYu1MassceAgcUnknownInitState, which remains visible to the progress and overlap scanners. Validate versions using the existing register-default tables. For unregistered compute addresses, capture a bounded snapshot of readable mapped code and decode through the reachable program end. Instruction literals and forward branches do not terminate the scan prematurely. Snapshots grow geometrically within a 1 MiB limit; invalid alignment, inaccessible memory, and unterminated programs fail explicitly. Raw snapshots are reused by address while their entire readable code still matches, preserving the dispatch-cache key and source-handle memos. The LRU is limited to 64 entries and 8 MiB of code; guest memory reads and flushes occur outside its mutex. Code changes replace the immutable snapshot, concurrent misses deduplicate, and inaccessible code is rejected. Registered shaders retain their existing path, and headerless requests omit empty header memory regions.Tested
Windows 11, bundled MinGW, Release, rebased on main
fe98276f: this branch builds and passesagc_driverand the newly registeredagc_initializationCTest cases (2/2), each repeated three times. The unchanged-code snapshot regression fails before the cache fix. New tests cover stable identity, mutation, concurrent hits and misses, bounded eviction, a changed program end and revoked cached tail memory. The version-13 two-argument call preserves caller state, and both progress/overlap scanners recognize the renamed export. Raw-code tests cover literal end words, forward branch targets, immutable snapshots, misaligned/unmapped addresses, an inaccessible page boundary, an unterminated program, and an end instruction in the last readable dword. Initialization tests check both signatures and rejected versions.The broader, previously unregistered
agc_command_testsinvocation without thedefaultsoption fails an unrelated expected-exception check before reaching the initialization checks; no full-command-test pass is claimed.Integration with #683 (runtime exports), #684 (import binding), and #553: the original integration based on
af92452fbuilt and passed 290/290 CTest tests on an RTX 4070, followed by the new initialization regression passing. DOOM Shareware homebrew PPSA99666 01.001.000 reached E1M1 with AGC compute presentation, movement, and shooting. Main already supplies FLAT/GLOBAL stores and #614; their implementations are not duplicated here.Limits observed: a cold start during concurrent GPU tests exceeded the homebrew's frame deadline and activated its own CPU scaler. Restarting with the compiled shader cache used AGC presentation. A nonterminating UCRT invalid-parameter diagnostic is also present at startup. These are not claimed fixed. No FPS benchmark or audible audio verification claimed.
Updated integration on main
fe98276fwith the repaired #683/#684/#685 and #553: full build plus the runtimelibstarget succeeded; all nine focused integration tests passed. DOOM Shareware reached E1M1 again with movement and shooting through AGC compute presentation. Profiling recorded 3,798 dispatch-cache hits in 3,800 dispatches with zero evictions. This is cache-use evidence, not an FPS benchmark. Cold shader compilation can still exceed the homebrew frame deadline and trigger its CPU scaler; a warm restart used AGC. The startup UCRT diagnostic remains. Updated Linux and Windows CI pass.Checklist
fe98276f; open PRs checked for these functionsIn-game screenshots
Two E1M1 gameplay captures from the integrated DOOM Shareware homebrew run, showing the final integration build and movement/shooting. The integration dependencies and limits are described above.
Imported from boykopovar/AnyPS5. Originally posted by nicolasabosch on 2026-10-05T15:25:04Z.
In-game screenshots from the DOOM Shareware homebrew integration described above (Windows 11 / RTX 4070, with #683, #684 and #553). E1M1 loaded successfully; movement and shooting were checked. These captures show the integrated game run, not a standalone result from this PR.
E1M1 on the final integration build:
E1M1 after moving and firing the pistol:
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-05T19:45:47Z.
Thanks, this is a useful path for homebrew, and the registered-shader path stays as it was. I have one question about the dispatch cache and a small naming note.
Dispatch cache key for raw programs.
ReadRawComputeShaderbuilds a newShaderSnapshoton every dispatch, andDispatch.cppmixes the snapshot pointer into the key (if (!stampValidate()) mix(reinterpret_cast<std::uintptr_t>(registeredShader.get()))).APS5_DISPATCH_STAMP_VALIDATEis off by default, so each raw dispatch gets a new key. That means:insertDispatchagain every time (up to 1 MiB of code read per dispatch);dispatchCacheEntries()), a homebrew that dispatches every frame keeps evicting the other entries.This may be what you saw on the cold start that missed the homebrew's frame deadline. Would it work to keep the raw snapshots in a small map keyed by the address, and reuse one while its code words still match (or until the range is written)? Then the pointer stays stable and the key can hit.
Naming.
sceAgcInitState_nid_no_patchkeeps the23LRUSvYu1Mbehaviour that PPSA21564 relies on: it calls that NID with a state pointer and version 13, and the behaviour is unchanged. Buttools/progress.pyandtools/pr_overlap.pyskip every definition that ends in_nid_no_patch, so this export would drop out of the progress count and the overlap check. A name likesceAgcUnknownInitState(the same pattern as #651'ssceAgcUnknownCreateInterpolantMapping) would avoid that.kW3GLb7QfPgdoes recompute tosceAgcInit, so that part looks right to me.The rest looks right to me: the registered path picks the same snapshot as before, and the header region is still passed when it isn't empty.
Locally (Linux, GCC, NVIDIA): the new Submit cases don't build on main's code, and with the change
agc_driverpasses andagc_initializationpasses 20 times in a row.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-06T01:52:33Z.
Progress report (
fe98276→e5191eb)➖ System libraries: 81.6% (+0.0%, +1 implemented functions)
✅ 1 implemented
sceAgcUnknownInitStateImported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-06T03:27:20Z.
Thanks, both points are covered. Raw snapshots are now reused per address while their code still compares equal (after flushing GPU writes), so the dispatch key stays stable and a hit no longer reads and decodes again, and the cache is bounded at 64 entries and 8 MiB. The new cases (identity on unchanged code, a new snapshot on changed code, concurrent readers, eviction, and the Windows tail and revoke cases) cover what I was worried about.
sceAgcUnknownInitStatekeeps23LRUSvYu1M, and it stays visible to the progress and overlap tools now.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-06T03:28:02Z.
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/Execution/src/Driver/Dispatch/Dispatch.cppL229core/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cppL229core/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cppL229