fix(agc): zero-fill a vertex fetch past the record count #2573

Merged
oneandonlydean merged 1 commit from upstream-pr/2573 into main 2026-10-10 08:13:05 +00:00
oneandonlydean commented 2026-10-10 06:49:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-10T06:49:06Z.


Carrying @danzaio's fix for #2241 while PR intake is paused. The change is theirs (from danzaio/AnyPS5:fix/2241-oob-vertex-fetch, fd3ac4e9), with its three commits squashed and rebased onto current main.

What

A strided vertex fetch at or past the descriptor's num_records now reads (0, 0, 0, 0) for OOB_SELECT 0 and 1 instead of throwing. VertexBufferReadSize spans the whole fetch. The staging copy reads the record bytes and zero-fills from num_records * stride onward. Each such fetch gets its own copy, outside the shared copies of its sibling attributes, the host-import in-place path and the draw-snapshot cache. OOB_SELECT 2 and 3 still throw past num_records, since each needs its own rule. Zero-stride descriptors keep their existing checks (#1769 and the later OOB_SELECT rules for them).

Rebase note: since the branch's base, main added in-place vertex reads from host imports and a zero buffer for out-of-range zero-stride fetches. The past-records fetches go alongside these, are excluded from the in-place path, and get the same per-attribute handle and offset mapping. The zero-stride byte check keeps ZeroStrideAvailableBytes.

Why

Fixes #2241. Astro's Playroom (PPSA01325) draws its post-process and composite passes as a 4-vertex triangle strip over a 3-record vertex buffer, and aborts:

[videoout] presentation failed: AGC graphics: vertex fetch exceeds descriptor record count

simonbbby measured the hardware result on RDNA2 (gfx1036) with tools/hw-oracle in the issue. With OOB_SELECT 0 or 1, indices past the records return 0 in all four components, W included, unlike Vulkan's robustBufferAccess (0, 0, 0, 1). OOB_SELECT 2 and 3 follow other rules, measured in the same thread.

Tested

  • The author's runs: the validation tests cover VertexBufferReadSize for OOB_SELECT 0 to 3, vertexZeroFillTests covers the zero-padded copy, and vertexZeroFillMergeTests covers the split from shared copies. simonbbby's agc_driver_vertex_fetch_past_records execution test (on their branch) also passes on the author's branch, on an RTX 4050 on Windows. It covers an in-range draw that follows a past-records draw at the same address.
  • On current main 092e133e: the branch merges cleanly and tools/check_conventions.py passes. CI runs the build and tests.

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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4809368721 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2573). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-10T06:49:06Z. --- Carrying @danzaio's fix for #2241 while PR intake is paused. The change is theirs (from `danzaio/AnyPS5:fix/2241-oob-vertex-fetch`, fd3ac4e9), with its three commits squashed and rebased onto current `main`. ### What A strided vertex fetch at or past the descriptor's `num_records` now reads `(0, 0, 0, 0)` for `OOB_SELECT` 0 and 1 instead of throwing. `VertexBufferReadSize` spans the whole fetch. The staging copy reads the record bytes and zero-fills from `num_records * stride` onward. Each such fetch gets its own copy, outside the shared copies of its sibling attributes, the host-import in-place path and the draw-snapshot cache. `OOB_SELECT` 2 and 3 still throw past `num_records`, since each needs its own rule. Zero-stride descriptors keep their existing checks (#1769 and the later `OOB_SELECT` rules for them). Rebase note: since the branch's base, `main` added in-place vertex reads from host imports and a zero buffer for out-of-range zero-stride fetches. The past-records fetches go alongside these, are excluded from the in-place path, and get the same per-attribute handle and offset mapping. The zero-stride byte check keeps `ZeroStrideAvailableBytes`. ### Why Fixes #2241. Astro's Playroom (PPSA01325) draws its post-process and composite passes as a 4-vertex triangle strip over a 3-record vertex buffer, and aborts: ``` [videoout] presentation failed: AGC graphics: vertex fetch exceeds descriptor record count ``` simonbbby measured the hardware result on RDNA2 (gfx1036) with `tools/hw-oracle` in the issue. With `OOB_SELECT` 0 or 1, indices past the records return 0 in all four components, W included, unlike Vulkan's `robustBufferAccess` (0, 0, 0, 1). `OOB_SELECT` 2 and 3 follow other rules, measured in the same thread. ### Tested - The author's runs: the validation tests cover `VertexBufferReadSize` for `OOB_SELECT` 0 to 3, `vertexZeroFillTests` covers the zero-padded copy, and `vertexZeroFillMergeTests` covers the split from shared copies. simonbbby's `agc_driver_vertex_fetch_past_records` execution test (on their branch) also passes on the author's branch, on an RTX 4050 on Windows. It covers an in-range draw that follows a past-records draw at the same address. - On current `main` 092e133e: the branch merges cleanly and `tools/check_conventions.py` passes. CI runs the build and tests. ### 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
github-actions[bot] commented 2026-10-10 08:01:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T08:01:12Z.


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.

Pull request Conflicting files (lines on main) Same exports Same new files
#1940 docs/dev/TechnicalDebt.md L420
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6095432344 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2573#issuecomment-6095432344). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-10T08:01:12Z. --- <!-- pr-overlap --> 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**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #1940 | `docs/dev/TechnicalDebt.md` [L420](https://github.com/boykopovar/AnyPS5/blob/3539d1ce0b5eafbcc56945e8f8fd783f3d90775a/docs/dev/TechnicalDebt.md#L420) | | |
danzaio commented 2026-10-10 08:08:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by danzaio on 2026-10-10T08:08:37Z.


Validated the carried branch on real hardware: RTX 4050 laptop, Windows, MinGW 15.2 build of 5e3268969, ANYPS5_GPU=4050. agc_driver_graphics passes in about 14s, including the vertexZeroFillTests and vertexZeroFillMergeTests. AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6095532857 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2573#issuecomment-6095532857). Originally posted by [danzaio](https://github.com/danzaio) on 2026-10-10T08:08:37Z. --- Validated the carried branch on real hardware: RTX 4050 laptop, Windows, MinGW 15.2 build of 5e3268969, ANYPS5_GPU=4050. agc_driver_graphics passes in about 14s, including the vertexZeroFillTests and vertexZeroFillMergeTests. AI-assisted: yes.
adriadam10 commented 2026-10-10 08:13:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T08:13:02Z.


Checked on current main: build + ctest for libSceAgcDriver (agc_driver_graphics, agc_driver_prepared_graphics pass), the new tests fail to build without the change, OOB_SELECT 2/3 and zero-stride paths unchanged, the TechnicalDebt entry records the HW measurement from #2241. Merging.

Note: this conflicts with #1426 (Draw.cpp) and #1940 (TechnicalDebt.md), so whichever lands second needs a rebase.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6095566594 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2573#issuecomment-6095566594). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-10T08:13:02Z. --- Checked on current main: build + ctest for libSceAgcDriver (`agc_driver_graphics`, `agc_driver_prepared_graphics` pass), the new tests fail to build without the change, `OOB_SELECT` 2/3 and zero-stride paths unchanged, the TechnicalDebt entry records the HW measurement from #2241. Merging. Note: this conflicts with #1426 (`Draw.cpp`) and #1940 (`TechnicalDebt.md`), so whichever lands second needs a rebase.
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!2573
No description provided.