fix(agc): leave the primitive restart index out of an indexed draw's vertex range #1968
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1968"
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 lubaxe on 2026-10-09T03:25:55Z.
What
An indexed draw sizes its vertex buffer copies from the highest index in its index buffer. That scan counted the primitive restart index (all ones) as a vertex. A 16-bit strip draw with restart in PPSA12544 then needed vertex 65535 of a 4957-record buffer, and the draw threw
vertex fetch exceeds descriptor record count.HighestDrawIndexinVertexInput.hpp. When the draw's pipeline enables restart, it skips the restart index. The condition is the same asprimitiveRestartEnableinPipeline.cpp(primitiveRestartand, for list topologies,primitiveListRestart).SnapshotUse::Index16RestartandIndex32Restartkeys, so a buffer drawn with and without restart never shares the cached value.Tested
highestDrawIndexTestsinagc_driver_graphics: 16- and 32-bit indices, with and without restart, a draw of only restart indices, and a range shorter than the data. Without the skip it fails witha 16-bit restart index counted as a vertex.agc_driver_scalar_swappc_fetch: an indexed strip of six restart indices over a vertex buffer with 0 records draws nothing and runs no vertex. With the old behaviour it fails withvertex fetch exceeds descriptor record count. (Added in edad2a16 after review; rebased ontomaind70b8998.)ctest: 487 of 488 passed. The failure isagc_driver_pixel_lds, which also fails on unmodifiedmainon this GPU (vkWaitForFences graphics: Vulkan result -4).agc_driver_recorder_tests, run directly: passed.tut_01.tools/check_conventions.py --base origin/mainpasses.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T03:43:49Z.
Review: COMMENTED
The all-restart helper case still flows into vertex-input preparation with
inputs.maxIndex == 0.VertexBufferReadSizethen validates and copies vertex record 0 for every per-vertex attribute, so an indexed draw containing only restart markers can still fail on an empty/out-of-range vertex descriptor or read data that the draw never references. Could you track whether the range contains any non-restart index and skip per-vertex reads for an all-restart draw, with an end-to-end draw test? The currentrestartOnlyassertion exercisesHighestDrawIndexalone and does not cover this downstream path.Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-09T04:36:43Z.
Linux results, since this was tested on Windows only. Everything passes here.
Nobara 44 (Linux 7.2), GCC 16.2.1, Release,
BUILD_TESTING=ON. This PR merged ontomainf1451396cleanly.mainf1451396main+ this PRctest -R agc_driver -j1-E agc_driver)The CPU failure is
guest_dynamic_loader, which fails the same way onmain.Imported from boykopovar/AnyPS5. Originally posted by lubaxe on 2026-10-09T12:59:00Z.
Thanks, you were right. Addressed in edad2a16 (on top of a rebase onto
maind70b8998):HighestDrawIndexnow returnsstd::optional. It is empty when every index is the restart index and restart is in effect.prepareDrawInputsthen marks the draw as nothing to draw (inputs.nothing, the existing exit for zero-count auto draws) before any vertex input is validated or copied. An all-restart index buffer issues no primitives, so the vertex stage has nothing to fetch.Index16Restart/Index32Restartsnapshot uses stores the highest index plus one, so 0 means "no vertex" on a cache hit as well.agc_driver_scalar_swappc_fetch(ctest). It draws an indexed triangle strip with restart enabled, six restart indices and a vertex buffer V# with 0 records. The vertex shader stores every fetched vertex to a buffer. The test requires that the draw does not throw, writes no pixels and runs no vertex. With the old behaviour (an all-restart draw treated as vertex 0) it fails withvertex fetch exceeds descriptor record count, the failure you described.highestDrawIndexTestsalso checks the all-restart case without restart.Windows 11, RTX 5090:
ctest506 of 507. The failure isagc_driver_pixel_lds, which also fails on unmodifiedmainon this GPU.tools/check_conventions.pypasses.(AI-assisted: Claude Code.)
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T01:23:10Z.
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/src/Draw.cppL849-851, L853-866, L868-871