fix(agc): resolve sparse indirect index ranges per record #6606
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6606"
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 veosett on 2026-10-15T22:35:12Z.
What
An indexed indirect draw checks all of
INDEX_BUFFER_SIZEbefore reading its records. Guardians of the Galaxy (PPSA01748 v01.006.000) declares 512 MiB over about 54 MiB of mapped index memory and stops at that check during the first level load. Addresses #6526.Preserve the declared index limit and its address, alignment and overflow checks. If that range is not fully readable, use the existing driver CPU-record path: its checked record/count reads wait for preceding GPU writes, clamp against the original index limit, and validate and prepare only each record's actual index range. Unused holes and tails are not copied or scanned for index values; an active record reaching an unreadable page still throws. Fully readable buffers retain the existing GPU path. The profiler names the fallback
index range not fully readable.The regression compares rendering with a direct reference triangle: 16/32-bit indices, single/counted multi draws, GPU-written records/counts, accessible ranges before and after a hole, and records outside the declared limit. A separate case requires an unreadable active record to fail on its actual six-byte index range. The PM4 test now checks deferred validation while retaining overflow and alignment rejection.
The title report uses #6232 to pass an earlier shader blocker. This fix builds independently of it.
Tested
Merged base
main3259e4c3e; tested head94bd3c387. Release, bundled dependencies, SPIRV-Tools enabled.APS5_PIPELINED_DRAWS=0in 1.05 s, andshader_cache_native_paths1/1 in 1.69 s. No skips.agc_driver_pm4,agc_driver_draw_offset_indices,agc_driver_indirect_patched_stage,agc_driver_sparse_indirect_indicesandagc_driver_sparse_indirect_indices_unreadable. The unreadable case still rejects its active six-byte range.31cbb55d7plus only the new test (62b85a602), both sparse cases fail on Windows and Linux at the full declared-range check.Independent title evidence: Tamalero's comparison reports three Guardians of the Galaxy runs on two bases with this PR and #6232; the index-range stop is removed and the title reaches a separate compute-shader limitation. This is attributed integration evidence, not a local title run.
Not run here: titles, the full CTest suite, or a performance comparison.
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 github-actions[bot] on 2026-10-15T23:30:00Z.
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.
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/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/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/Draw.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/Draw.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/Draw.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Pm4.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Pm4.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Pm4.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Draw.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.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/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Execution/src/Pm4.cppcore/libs/prx/libSceAgcDriver/tests/Pm4.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.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/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/Draw.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/Draw.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Pm4.cppcore/libs/prx/libSceAgcDriver/tests/Pm4.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.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/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/Draw.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtImported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-16T01:26:20Z.
Review: COMMENTED
Ran this on NVIDIA, which the PR's GPU list doesn't include.
Machine: NVIDIA GeForce RTX 3070, driver 595.99.02, Vulkan 1.4.329, Ubuntu 26.04 (kernel 7.0.0-38), i7-8700. GCC 15.2, Release,
BUILD_TESTING=ON, selected withANYPS5_GPU="NVIDIA GeForce RTX 3070". Head925f9a84bmerged intomain5d9dcc42d.main):agc_driver_sparse_indirect_indicesandagc_driver_sparse_indirect_indices_unreadablefail withguest memory is not readable at ... (range ...ff0+0x20000000), andagc_driver_pm4with the same check on+0x1fffffffc. That is the full-range check the PR describes.agc_driver_pm4*,draw_offset_indices,indirect_patched_stage, bothsparse_indirect_indicesmodes, 10 tests) passes 3/3, and 1/1 withAPS5_PIPELINED_DRAWS=0.ctest -R "^agc|shader|recompiler" -j1(flip, display andlds_atomics64excluded): same asmainplus the new test. The only failure isagc_driver_store_over_untracked, which fails onmainhere too (#6347);stencil_ref_exportskips (noVK_EXT_shader_stencil_exporton this driver).GPUs tested: NVIDIA GeForce RTX 3070, driver 595.99.02, Ubuntu 26.04
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by SleglJan on 2026-10-16T03:24:29Z.
A run on a second title with the same stop: 007 First Light (PPSA11386 v01.018.000), on Linux 7.2.10, NVIDIA GeForce RTX 3080 10 GB, driver 615.78.08, GCC 16.2.1, Release with
BUILD_TESTING=ON, in a bubblewrap sandbox. Head925f9a84bmerged on top of a bring-up stack:main4186f06a9plus open PRs, unpublished local fixes the title needs to get this far, local logging and scripted input, and the title's two feedback-wait limits widened in its executable as described in #6172 (local only); the merge bringsmainup to5d9dcc42d. A local change for the same stop that the stack otherwise carries was taken out for this run, so the title's indirect index ranges go through this PR's fallback alone.The title declares 16-bit indices with
INDEX_BUFFER_SIZE0xffffff, a 32 MiB range, over several separate direct mappings with unmapped pages between them. Without a change for it the title stops at the level load withAGC driver: guest memory is not readable at … (range …+0x1fffffe).APS5_PROFILE_DRAW=1): 2030 indirect draws tookindex range not fully readable, every CPU-side indirect draw of the run (32,629 went GPU-side). They came between presents 1093 and 1223, in 127 of the 152 profile windows (10 s or longer each) from the first of them to the end of the run: 2 to 60 per window, median 14; 6 per window up to present 1119, mostly 30 to 60 over presents 1121-1155, 2 to 20 after that.argument readsfor these draws (the count and record reads, with their waits for recorded GPU writers) came to 1610.7 ms in total, 0.79 ms per draw on average; 66 of those 127 windows read under 1 ms, the top tenth over 42 ms, the largest 78.9 ms. The per-record draws after the reads are counted with the ordinary draw phases and are not separated.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by Tamalero on 2026-10-16T07:22:15Z.
Title check for #6526 on Marvel's Guardians of the Galaxy (PPSA01748): with this PR the title gets past the indirect indexed draw that #6526 reports.
Same tree with and without this PR's two commits:
main03c4cb5e7+ #6232 (6b662dd8b), which the title needs to get this far. The PR was cherry-picked onto that base (no conflicts). Same relinked executable and route for every run: start a game from the menu and let it load the first level.AGC driver: guest memory is not readable at 0x3865a0000 (range 0x383240000+0x20000000)/0x386590000, the #6526 draw (DRAW_INDEX_INDIRECT_MULTI,INDEX_BUFFER_SIZE0x10000000)not readablestop; the title runs on until it dispatches compute shader0x3b91c3e00That next stop is a separate, already known limit:
ShaderRecompiler::Recompile: GetImageResource dword 0 is not a valid runtime valueatpc=0x00004380. The same shader fails to prepare at registration in all three runs; it only becomes fatal once the title dispatches it, which the runs without this PR never reached. It's the key noted as unplanned in #6191.Details
Linux (CachyOS), RTX 4090, i9-14900K, GCC 16.2.1, Release. The title was relinked with
--to-intelby the relinker at03c4cb5e7. Not tested: AMD, Windows, or this PR on its own base5d9dcc42d.Tested and written by Claude (AI assistant) on a contributor's machine.
Imported from boykopovar/AnyPS5. Originally posted by Tamalero on 2026-10-17T04:47:20Z.
Follow-up: the same result on this PR's own base. Tree
main5d9dcc42d+ #6232 (6b662dd8b) + this PR's two commits (cherry-picked unchanged), same title, route and relinked executable as above, warm shader cache, 2 runs: neither has aguest memory is not readablestop; both run on to the dispatch of compute shader0x3b91c3e00(GetImageResource dword 0 is not a valid runtime valueatpc=0x00004380) about 2 minutes in, as in the first run.That's three runs with this PR, on two bases, against two control runs without it that stop at the #6526 draw.
Tested and written by Claude (AI assistant) on a contributor's machine.
Imported from boykopovar/AnyPS5. Originally posted by marco-scheffler on 2026-10-17T14:09:17Z.
Linux NVIDIA data point: Ubuntu 24.04.4, RTX 4000 SFF Ada Generation, driver 595.99.02, GCC 13.3.0, Release. This PR at
925f9a84bmerged ontomainc9e6c45de, fullcteston the RTX (ANYPS5_GPU=RTX, Xvfb with-DANYPS5_VIDEO_OUT_TEST_DRIVER=x11): no new failures. The only failures,video_out_flip_eop{,_main,_aftergpu}(#6616) andagc_driver_{f16_fma,fma_mix_f16}_denormal_modes, fail the same way on thatmain(0/5 serial with and without this PR).Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-18T10:46:51Z.
I can cross-test this on 007 First Light (PPSA11386) on Windows11/RTX5070Ti617.42. Our integration 8e0bd2cc640e8cbc9efb2f92d73ccaa7f589abac (base
e5c2b3c32plus public 007/shared-table/resource stack) reaches the rendered offline menu at1.963FPS, then Resume aborts during the level load on a full index-range readability check. The local packet diagnostics show INDEX_BUFFER_SIZE=0x00ffffff followed by DRAW_INDEX_INDIRECT; 16-bit indices give the failing declared0x1fffffe-byte span, with an unreadable gap. This looks like the same class as #6526. Raw title data stays local; no title result claimed for #6606 yet.I fetched925f9a84b and will first build/run the five focused native controls here, then test that level transition. No duplicate implementation. I will report a genuinely unreadable active record separately rather than hiding it or padding the tail. Game has exited; no native tests/builds overlap it. AI-assisted: Codex.
Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-18T10:50:16Z.
Windows RTX5070Ti/617.42 results on integration ad3586f18b2594002d4ce2af639234ad86778aef, carrying exact #6606 head925f9a84b: 5/5 focused controls PASS2.37s; both sparse-indirect modes with APS5_PIPELINED_DRAWS=0 PASS0.98s; four related import-settle/draw-cache/relocation controls PASS1.90s. Zero skips; ANYPS5_REQUIRE_VULKAN=1. Full native binaries are used (ANYPS5_AGC_EXECUTION_TESTS is empty). Conventions pass; source is clean/pushed at https://github.com/Scramblrrrr/AnyPS5/tree/codex/first-light-oct18-current . The seven-file merge was clean. These are integration cross-tests, not a claimed main-only/Guardians title result.
Matched patched graphics modules are staged, and 007 is restarting with the same warm cache/settings/guards as the preceding declared-range failure. No title outcome for this candidate yet. No build or GPU test runs concurrently with the game. AI-assisted: Codex; title data stays local.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T08:48:59Z.
Checked the per-record path: the CPU fallback reads the records through the checked path, clamps against the declared index limit (
Draw.cppindexed branch) and validates only each record's actual range; the overflow and alignment checks stay inresolveIndirectDraw. The new tests pin both the sparse draws and the six-byte unreadable failure, and the title and NVIDIA/Windows cross-runs in the thread cover what we can't run. Merged.