fix(agc): validate mesh index descriptors on cached draws #5791
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5791"
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 Ondra97 on 2026-10-14T11:07:13Z.
What
Fixes the missing logo, text and language buttons in VLC PPSA85300 v0.4 (#5731, bring-up #5732). NGG draws can share register and SRT state while their
DRAW_INDEX_2packets select different index ranges. The generated index descriptor is absent from the register key and captured SRT memory, so a cache hit can retain the previous draw's index buffer descriptor.Retain its four words with each mesh stage variant, require them to match before reuse, and include them in variant deduplication. A matching push offset with a different descriptor counts as a differing front stage. The regression checks rendered pixels, count and address changes, miss classification, reuse of each changed descriptor, and return to an earlier descriptor. It shares the existing NGG fixture with the mesh test.
The metadata field and capture sit beside the compiled result, keeping the insertions separate from the relocation fields in #4943 and #5609. Neither PR implements this correction; both merge cleanly with this branch.
Tested
Current head
ed26cb81a, based on maina453108cf. Windows 11 Pro 10.0.26300, WinLibs GCC 15.2.0, NVIDIA GeForce RTX 4070 Ti SUPER, driver 32.0.16.1714 / NVIDIA 617.14.agc_shader_memory,agc_driver_mesh,agc_driver_mesh_index_cache,agc_driver_draw_cache_reuse,agc_driver_draw_cache_reuse_off, andagc_driver_prepared_graphics.84b01f9cd, removing the descriptor match makes it fail at the rendered-pixel assertion when the index count grows from 3 to 6; restoring the match passes again. The subsequent rebase adds only the independent Voice reset-port change.8260e3c44, then 60 s on the final rebased head. I checked the original BMP pixels and enlarged crops. All 129 runtime library copies were hash-verified; the final driver contains no temporary diagnostic flags. This validates the welcome page; media playback and input beyond it were not tested.--windows --registry --windows-fixed-base 0x400000and its bundled libc. Executable ELF SHA-256:eec51934aa2debed99152c3996f39a41be25e17d9ca14de01cee2d17b62d8e3f; the unwrapped payload segments were independently verified.git merge-treesucceeds with #49431c72efdc9and #5609d6abd5555. Earlier combined-tree validation with their changes passed eight focused tests on maincaee23fd9; that tree was not pushed.Correction to the earlier draft note: I misread the full-frame previews when reporting that the lower three rows were missing. The original BMP files contain all four rows and their labels, including the normal-cache runs. The clean runs above confirm that result; no speculative cache changes or diagnostic code are included.
External validation of earlier rendering-fix heads:
d41effbacon main23be5a02b. The mesh-index and draw-cache reuse cases passed three repetitions; the 48 s VLC run showed all 16 buttons and hints. The Linux conversion used #4593 for its fixed base. I did not run Linux locally.d1e050d4con main9a3e2ac4d. Both 60 s runs showed the complete welcome page; the mesh and mesh-index cases passed three repetitions. These results are for the stated earlier heads.Window closure still aborts on this rendering branch (
0xc0000409), as in the main control and external Windows runs. That separate fix is in #5843, which depends on #5236. Full Linux/Windows runtime CI requires a write-access collaborator to dispatch it under repository policy.Checklist
main; no other open PR implements the same functionsd41effbac; AMD Radeon 860M, driver 32.0.13058.8001, Windows 11 26300 atd1e050d4cImported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-14T11:23:48Z.
Linux check of this PR, and one note on how a mismatch is counted.
Setup: Bazzite 44, GCC 16.2, Release, RX 7700 XT with RADV (Mesa 26), head
d41effbacmerged ontomain23be5a02b.agc_driver_mesh_index_cache,agc_driver_draw_cache_reuseandagc_driver_draw_cache_reuse_offpass 3 of 3 (--repeat until-fail:3).--linux-fixed-base 0x400000), first-run page, 48 s, captured at 40 s: onmainonly the gradient and the page dots; with this PR the logo, "Welcome to VLC", all 16 language buttons with their labels and the Continue/Skip hints, at 59.94 fps. That's the same pageAPS5_NO_DRAW_KEYgives onmain.The note: in
lookupDrawthe descriptor checkcontinues beforeanyLayout = true. So when no variant matches the draw's index range,missbecomesDrawMiss::Layout, and the draw-cache report (APS5_PROFILE_DRAW) shows these draws under "layout (push offset)" instead of "front stage differing". I hit this with a test of my own: four indexed draws of an NGG program with one register key (first range twice, another range, the first again), checking that the third draw misses as a differing front stage. Against this PR the third draw does miss, but it's counted as a layout miss, so a front-stage check reads 0. Marking the mismatch as differing would keep the statistics honest, for example:Your dedupe change in
insertDrawEntryis needed too: without it, a variant that differs only in the descriptor is taken as already present and never inserted, so draws over that range would miss every time.Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-14T12:18:20Z.
@YossiYad Thanks for checking this on Linux/RADV and confirming the VLC rendering fix on the RX 7700 XT.
I reproduced the statistics issue and corrected it in
d1e050d4c. When the push offset matches but the mesh index descriptor differs, I now mark the layout as present and classify the mismatch asEntryOutcome::Differing, preserving the existing first-candidate outcome handling.I extended
agc_driver_mesh_index_cacheto check that both range and address changes incrementFrontDifferingwithout incrementingLayout. It also checks cache hits when each changed descriptor is repeated and when returning to the earlier descriptor, covering the deduplication requirement you pointed out. The classification assertion failed before the correction and passes afterward.I rebased onto main
51031742e. The full Windows Release build and all six focused CTest cases passed; the strengthened regression also passed three consecutive runs with GPL disabled on my RTX 4070 Ti SUPER.AI-assisted: yes. — Codex
Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-14T12:50:50Z.
Windows/AMD check with VLC (PPSA85300 v0.4, catalog release): Windows 11 (26300), Radeon 860M (RDNA 3.5, driver 32.0.13058.8001), WinLibs GCC 15.2.0, Release. Relinked with
--windows --registry --windows-fixed-base 0x400000, 60 s per run, frames fromAPS5_DUMP_FRAMES(one every 600 presents).main9a3e2ac4dmain9a3e2ac4d+ this PR (d1e050d4c)mainThe window title reads 20.0 FPS on
mainand 27.4 / 29.2 FPS with the PR.agc_driver_meshandagc_driver_mesh_index_cachepass 3 of 3 (--repeat until-fail:3) with an empty test shader cache.Not tested: the new test against
main's sources, input past the welcome page. All runs end withabort()(exit 0xc0000409) when the window is closed at 60 s, with and without the PR.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-15T01:53:41Z.
Windows/NVIDIA check with VLC (PPSA85300 v0.4, catalog release).
ed26cb81amerged ontomain2559e9623: clean, no conflicts (merge96f751835). Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release, NVIDIA GeForce RTX 4070 (driver 596.21).libspass; the only warnings are the existing onesmainalso has (-Wstringop-overreadinPipelineLibrary.cpp/ShaderFusion.cpp,u8pathinGeneral.cpp).ANYPS5_REQUIRE_VULKAN=1,--repeat until-fail:3:agc_driver_mesh_index_cache,agc_driver_draw_cache_reuse,agc_driver_draw_cache_reuse_off,agc_driver_mesh,agc_shader_memory,agc_driver_prepared_graphics: 6/6, 3 of 3.agc_driver_mesh_index_cache_tests.exewithmain'slibSceAgcDriver.prxfirst onPATHexits 1 withAGC graphics: cached mesh draw used another draw's indices: count=6.ctest -R '^agc_'with the display available: 565/565 passed (3 skipped, the same asmain's 564/564).ctest -j8 --timeout 120 -E '^agc_driver_|^video_out_flip': 810/812 on the first pass.hardware_oracle_compare(20 s limit) timed out, as it also does onmainunder-j8.guest_file_lock_processexited0xc0000409after 11.6 s under load. Both pass 3 of 3 when rerun alone,guest_file_lock_processpasses in themainsuite, and neither test involves libSceAgcDriver.relinker --windows --registry unused-filter=0 --windows-fixed-base 0x400000, 60 s, window captured withPrintWindowat 20 s and 50 s, plusAPS5_DUMP_FRAMESat present 1200:main2559e9623VLC | FPS: 72.31 (4432)main+ #5791VLC | FPS: 90.28 (5333)No stop line in either build. With this PR alone, closing the window still exits
0xC0000409(after 1.1 s), as onmain; #5843 fixes that. FPS varied with other load on the machine, so these figures do not support a performance claim.Verdict: the missing welcome-page text and buttons are fixed on NVIDIA too, with no AGC test regressions.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:09:40Z.
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/Draw/DrawCache.cppL128Some 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/Execution/src/Driver/Draw/DrawCache.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCapture.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawLookup.cppcore/libs/prx/libSceAgcDriver/Execution/include/Driver/Dispatch/DispatchCache.hppcore/libs/prx/libSceAgcDriver/Execution/include/Driver/Dispatch/DispatchCache.hppcore/libs/prx/libSceAgcDriver/Execution/include/Driver/Dispatch/DispatchCache.hppcore/libs/prx/libSceAgcDriver/Execution/include/Driver/Dispatch/DispatchCache.hppcore/libs/prx/libSceAgcDriver/Execution/include/Driver/Dispatch/DispatchCache.hppcore/libs/prx/libSceAgcDriver/Execution/include/Driver/Dispatch/DispatchCache.hppcore/libs/prx/libSceAgcDriver/Execution/include/Driver/Dispatch/DispatchCache.hppcore/libs/prx/libSceAgcDriver/Execution/include/Driver/Dispatch/DispatchCache.hppcore/libs/prx/libSceAgcDriver/Execution/include/Driver/Dispatch/DispatchCache.hppcore/libs/prx/libSceAgcDriver/Execution/include/Driver/Dispatch/DispatchCache.hppcore/libs/prx/libSceAgcDriver/Execution/include/Driver/Dispatch/DispatchCache.hppcore/libs/prx/libSceAgcDriver/Execution/include/Driver/Dispatch/DispatchCache.hppcore/libs/prx/libSceAgcDriver/Execution/include/Driver/Dispatch/DispatchCache.hppcore/libs/prx/libSceAgcDriver/Execution/include/Driver/Dispatch/DispatchCache.hppcore/libs/prx/libSceAgcDriver/Execution/include/Driver/Dispatch/DispatchCache.hppcore/libs/prx/libSceAgcDriver/Execution/include/Driver/Dispatch/DispatchCache.hppcore/libs/prx/libSceAgcDriver/Execution/include/Driver/Dispatch/DispatchCache.hppcore/libs/prx/libSceAgcDriver/Execution/include/Driver/Dispatch/DispatchCache.hppcore/libs/prx/libSceAgcDriver/Execution/include/Driver/Dispatch/DispatchCache.hppcore/libs/prx/libSceAgcDriver/Execution/include/Driver/Dispatch/DispatchCache.hppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCache.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCapture.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawLookup.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCache.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCapture.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawLookup.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawLookup.cppcore/libs/prx/libSceAgcDriver/tests/Mesh.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCache.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCapture.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawLookup.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawLookup.cppImported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-15T13:16:28Z.
Checked the three-line change in
DrawCapture/DrawLookup/DrawCacheagainst the cache flow: the mesh index descriptor is retained per stage variant, required to match on lookup, and part of the variant dedup. A push-offset match with a different descriptor is counted asFrontDiffering.Built and ran the AgcDriver tests on the PR merged onto current main: all pass except
agc_driver_tessellation, which segfaults on main as well.agc_driver_mesh_index_cachefails when the non-test changes are reverted, so it tests the fix. Thanks to @YossiYad, @LeandroLP23 and @screamm for the Linux/AMD, Windows/AMD and Windows/NVIDIA runs; merging.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-15T20:15:47Z.
Reverted by #6552:
agc_driver_mesh_index_cacheaborts on the linux job of every main push build since this merged (lavapipe LLVM 20.1.2,LLVM ERROR: Cannot emit physreg copy instructioncompiling the test shaders; e.g. run 38786745473). Please reopen with a test shader that the runner's lavapipe compiles; the linux job must pass before it lands.