fix(agc): bind a null index buffer to non-indexed mesh draws #1134

Merged
alfalfa-star merged 1 commit from upstream-pr/1134 into main 2026-10-08 08:15:10 +00:00
alfalfa-star commented 2026-10-07 13:25:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by alfalfa-star on 2026-10-07T13:25:59Z.


What

Non-indexed mesh draws no longer fail with writable guest memory overlaps an immutable snapshot (or guest snapshot differs from the writable memory it overlaps).

For a non-indexed draw (DRAW_INDEX_AUTO, or a non-indexed indirect record), MeshIndexBufferDescriptor gave the mesh program's hidden index-buffer V# (user words 4..7) a 4-byte range at the program's own code address. The prologue never loads through it, because the load is predicated on the draw's index size. But the descriptor still had a guest address, so ShaderResources bound it from live guest memory (AddReadable). When the same program also reads guest memory by address, the address build captures the program's code as an immutable snapshot, and UploadPrepare refuses a live region that overlaps a snapshot. If the guest had rewritten the bytes at the code address since the capture, the draw failed in the snapshot compare instead.

  • MeshIndexBufferDescriptor returns a null V# for a non-indexed draw: base and size 0, same format word. ShaderResources binds that to its empty placeholder buffer, so no guest range is involved. The function no longer takes the unread address.
  • Indexed draws are unchanged.

Tested

Linux 7.2.9 (Arch), Mesa 26.2.4 RADV, RX 9070 XT.

  • PPSA14632 (LEGO Horizon Adventures) hit this on its layered mesh-path draws. Its programs live at host addresses (0x7f…), and the 4-byte live range sat at the start of the program's 0xa40-byte code snapshot. Before: 7 such skipped draws in a 60 s run (about 300 per 200 s on longer runs). With this change: none in 180 s.
  • agc_driver_graphics: new meshIndexBufferTests (a non-indexed draw gets the null V#, an indexed draw keeps its address and rounded size, a null indexed buffer still throws).
  • agc_driver_mesh_tests (not in CI; needs VK_EXT_mesh_shader) passes. Its non-indexed draws now bind the null V#.
  • ctest: 396 of 396 pass.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4773319662 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1134). Originally posted by [alfalfa-star](https://github.com/alfalfa-star) on 2026-10-07T13:25:59Z. --- ### What Non-indexed mesh draws no longer fail with `writable guest memory overlaps an immutable snapshot` (or `guest snapshot differs from the writable memory it overlaps`). For a non-indexed draw (DRAW_INDEX_AUTO, or a non-indexed indirect record), `MeshIndexBufferDescriptor` gave the mesh program's hidden index-buffer V# (user words 4..7) a 4-byte range at the program's own code address. The prologue never loads through it, because the load is predicated on the draw's index size. But the descriptor still had a guest address, so `ShaderResources` bound it from live guest memory (`AddReadable`). When the same program also reads guest memory by address, the address build captures the program's code as an immutable snapshot, and `UploadPrepare` refuses a live region that overlaps a snapshot. If the guest had rewritten the bytes at the code address since the capture, the draw failed in the snapshot compare instead. - `MeshIndexBufferDescriptor` returns a null V# for a non-indexed draw: base and size 0, same format word. `ShaderResources` binds that to its empty placeholder buffer, so no guest range is involved. The function no longer takes the unread address. - Indexed draws are unchanged. ### Tested Linux 7.2.9 (Arch), Mesa 26.2.4 RADV, RX 9070 XT. - PPSA14632 (LEGO Horizon Adventures) hit this on its layered mesh-path draws. Its programs live at host addresses (0x7f…), and the 4-byte live range sat at the start of the program's 0xa40-byte code snapshot. Before: 7 such skipped draws in a 60 s run (about 300 per 200 s on longer runs). With this change: none in 180 s. - `agc_driver_graphics`: new `meshIndexBufferTests` (a non-indexed draw gets the null V#, an indexed draw keeps its address and rounded size, a null indexed buffer still throws). - `agc_driver_mesh_tests` (not in CI; needs `VK_EXT_mesh_shader`) passes. Its non-indexed draws now bind the null V#. - `ctest`: 396 of 396 pass. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
adriadam10 commented 2026-10-08 08:15:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T08:15:07Z.


Checked on current main: build and ctest green, addGuestBuffer binds a V# with base 0 or size 0 to the empty placeholder, indexed draws keep their address/rounded size and the invalid-range throw, and the new meshIndexBufferTests can't pass on main (signature change). CI green; merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6055700919 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1134#issuecomment-6055700919). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-08T08:15:07Z. --- Checked on current main: build and ctest green, `addGuestBuffer` binds a V# with base 0 or size 0 to the empty placeholder, indexed draws keep their address/rounded size and the invalid-range throw, and the new `meshIndexBufferTests` can't pass on main (signature change). CI green; merging.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!1134
No description provided.