PPSA01325: a 4-vertex strip over a 3-record vertex buffer stops on "vertex fetch exceeds descriptor record count" #2241

Closed
opened 2026-10-09 12:52:14 +00:00 by orbz22 · 4 comments
orbz22 commented 2026-10-09 12:52:14 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by orbz22 on 2026-10-09T12:52:14Z.


What happens

Astro's Playroom (PPSA01325) draws its post-process and composite passes as a fullscreen triangle stored in a 3-record vertex buffer. It submits that triangle as a 4-vertex triangle strip. The 4th vertex is past the descriptor's num_records. AnyPS5 refuses the fetch and the title aborts from presentation:

[videoout] presentation failed: AGC graphics: vertex fetch exceeds descriptor record count
terminate called after throwing an instance of 'std::runtime_error'
  what():  AGC graphics: vertex fetch exceeds descriptor record count

The check is Require(stride == 0 || index < records, ...) in Graphics/include/VertexInput.hpp.

The draw, traced locally:

field value
draw non-indexed, firstVertex 0, 4 vertices, triangle strip
vertex buffer num_records 3, stride 24, 2 attributes
descriptor word 3 0x0004dfac (OOB_SELECT 0, DST_SEL x, y, z, w)
v0 position (-1, -1, 0, 1), uv (0, 1)
v1 position (3, -1, 0, 1), uv (2, 1)
v2 position (-1, 3, 0, 1), uv (0, -1)
v3 past num_records; the bytes in memory there are unrelated

Seen on main 745b775e with the earlier PPSA01325 blockers applied (#1836, #1837, #1395 rebased). It is the next stop after #1395.

What the hardware does is the open question

The first triangle (v0, v1, v2) already covers the screen. What the second one (v1, v2, v3) does depends on what the fetch of v3 returns:

  • If an index past num_records with OOB_SELECT 0 returns 0 in every component, v3's position is (0, 0, 0, 0). The second triangle has a vertex with w = 0 and adds nothing. I believe this is what the console does.
  • Vulkan's robustBufferAccess instead returns (0, 0, 0, 1) for an out-of-bounds vertex attribute. The second triangle becomes a visible wedge from v1 and v2 to the screen centre. I saw this wedge locally when the fetch was let through that way.

I have not found a primary source for what a structured buffer_load_format_xyzw returns past num_records with OOB_SELECT 0, in particular whether W is 0 or 1 for a float format. Without that source I have not opened a PR. The local workaround I run cuts this draw's vertex count down to the records (4 to 3, since the first triangle is the whole image), and the title then renders correctly.

Ask

Could someone with an RDNA2 GPU on Linux run this through tools/hw-oracle (docs/dev/HW_ORACLE.md)?

  • Use a buffer_load_format_xyzw with idxen, an index of 3 and num_records 3, and the word 3 above (0x0004dfac).
  • Report the 4 returned dwords.

That settles which value the fetch should return. The fix is then either to fetch past the records with that value (0s) or to keep throwing, with this case documented.

Setup: Windows 11, RTX 3060 Laptop (NVIDIA 616.92), WinLibs GCC 15.2.

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5778399674 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2241). Originally posted by [orbz22](https://github.com/orbz22) on 2026-10-09T12:52:14Z. --- ### What happens Astro's Playroom (PPSA01325) draws its post-process and composite passes as a fullscreen triangle stored in a 3-record vertex buffer. It submits that triangle as a 4-vertex triangle strip. The 4th vertex is past the descriptor's `num_records`. AnyPS5 refuses the fetch and the title aborts from presentation: ``` [videoout] presentation failed: AGC graphics: vertex fetch exceeds descriptor record count terminate called after throwing an instance of 'std::runtime_error' what(): AGC graphics: vertex fetch exceeds descriptor record count ``` The check is `Require(stride == 0 || index < records, ...)` in `Graphics/include/VertexInput.hpp`. The draw, traced locally: | field | value | |---|---| | draw | non-indexed, `firstVertex` 0, 4 vertices, triangle strip | | vertex buffer | `num_records` 3, stride 24, 2 attributes | | descriptor word 3 | `0x0004dfac` (`OOB_SELECT` 0, `DST_SEL` x, y, z, w) | | v0 | position (-1, -1, 0, 1), uv (0, 1) | | v1 | position (3, -1, 0, 1), uv (2, 1) | | v2 | position (-1, 3, 0, 1), uv (0, -1) | | v3 | past `num_records`; the bytes in memory there are unrelated | Seen on `main` 745b775e with the earlier PPSA01325 blockers applied (#1836, #1837, #1395 rebased). It is the next stop after #1395. ### What the hardware does is the open question The first triangle (v0, v1, v2) already covers the screen. What the second one (v1, v2, v3) does depends on what the fetch of v3 returns: - If an index past `num_records` with `OOB_SELECT` 0 returns 0 in every component, v3's position is (0, 0, 0, 0). The second triangle has a vertex with w = 0 and adds nothing. I believe this is what the console does. - Vulkan's `robustBufferAccess` instead returns (0, 0, 0, 1) for an out-of-bounds vertex attribute. The second triangle becomes a visible wedge from v1 and v2 to the screen centre. I saw this wedge locally when the fetch was let through that way. I have not found a primary source for what a structured `buffer_load_format_xyzw` returns past `num_records` with `OOB_SELECT` 0, in particular whether W is 0 or 1 for a float format. Without that source I have not opened a PR. The local workaround I run cuts this draw's vertex count down to the records (4 to 3, since the first triangle is the whole image), and the title then renders correctly. ### Ask Could someone with an RDNA2 GPU on Linux run this through `tools/hw-oracle` (docs/dev/HW_ORACLE.md)? - Use a `buffer_load_format_xyzw` with `idxen`, an index of 3 and `num_records` 3, and the word 3 above (`0x0004dfac`). - Report the 4 returned dwords. That settles which value the fetch should return. The fix is then either to fetch past the records with that value (0s) or to keep throwing, with this case documented. Setup: Windows 11, RTX 3060 Laptop (NVIDIA 616.92), WinLibs GCC 15.2. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
simonbbby commented 2026-10-09 17:19:54 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by simonbbby on 2026-10-09T17:19:54Z.


Measured on RDNA2 with tools/hw-oracle at main d70b8998: gfx1036 (Ryzen 9 9950X iGPU), Linux 7.0 (Ubuntu 24.04), ROCm HSA runtime 5.7.1, LLVM 18.1.3. Float controls: ieee 0, dx10_clamp 1, denorm32 3, denorm16 3, round32 0, round16 0, fp16_overflow 0.

Body, with the vertex buffer passed as extra after the rows:

  s_add_u32 s8, s4, 512          ; 1024 for wave64
  s_addc_u32 s9, s5, 0
  s_and_b32 s9, s9, 0xffff
  s_or_b32 s9, s9, 0x180000      ; stride 24
  s_mov_b32 s10, 3               ; num_records
  s_mov_b32 s11, 0x4dfac
  buffer_load_format_xyzw v[10:13], v4, s[8:11], 0 idxen
  s_waitcnt vmcnt(0)

The buffer holds your three records (position, uv), then 72 bytes of 7.0, 8.0, 9.0, … where records 3 to 5 would be. v4 is the index, 0 to 5.

index v10..v13
0 bf800000 bf800000 00000000 3f800000 (-1, -1, 0, 1)
1 40400000 bf800000 00000000 3f800000 (3, -1, 0, 1)
2 bf800000 40400000 00000000 3f800000 (-1, 3, 0, 1)
3, 4, 5 00000000 00000000 00000000 00000000

Index 3 returns 0 in all four components, W included: (0, 0, 0, 0), not (0, 0, 0, 1).

The result past the records is the same in wave32 and wave64, in two runs each, and with RESOURCE_LEVEL 1 (0x0104dfac), OOB_SELECT 1 (0x1004dfac) and FORMAT 74 32_32_32_FLOAT (0x0004afac). As a control, the same descriptor with num_records 6 returns the stored values for indices 3 to 5 (7, 8, 9, 10 / 13, 14, 15, 16 / 19, 20, 21, 22), so the zeros come from the record check, not from memory.

gfx1036 is gfx10.3; docs/dev/HW_ORACLE.md lists the MUBUF encodings as shared with gfx1013.

If you're not already on the fix, I can open a PR that returns zeros past num_records instead of throwing.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6085777307 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2241#issuecomment-6085777307). Originally posted by [simonbbby](https://github.com/simonbbby) on 2026-10-09T17:19:54Z. --- Measured on RDNA2 with `tools/hw-oracle` at `main` d70b8998: gfx1036 (Ryzen 9 9950X iGPU), Linux 7.0 (Ubuntu 24.04), ROCm HSA runtime 5.7.1, LLVM 18.1.3. Float controls: `ieee 0`, `dx10_clamp 1`, `denorm32 3`, `denorm16 3`, `round32 0`, `round16 0`, `fp16_overflow 0`. Body, with the vertex buffer passed as `extra` after the rows: ``` s_add_u32 s8, s4, 512 ; 1024 for wave64 s_addc_u32 s9, s5, 0 s_and_b32 s9, s9, 0xffff s_or_b32 s9, s9, 0x180000 ; stride 24 s_mov_b32 s10, 3 ; num_records s_mov_b32 s11, 0x4dfac buffer_load_format_xyzw v[10:13], v4, s[8:11], 0 idxen s_waitcnt vmcnt(0) ``` The buffer holds your three records (position, uv), then 72 bytes of 7.0, 8.0, 9.0, … where records 3 to 5 would be. `v4` is the index, 0 to 5. | index | v10..v13 | |---|---| | 0 | `bf800000 bf800000 00000000 3f800000` (-1, -1, 0, 1) | | 1 | `40400000 bf800000 00000000 3f800000` (3, -1, 0, 1) | | 2 | `bf800000 40400000 00000000 3f800000` (-1, 3, 0, 1) | | 3, 4, 5 | `00000000 00000000 00000000 00000000` | Index 3 returns 0 in all four components, W included: (0, 0, 0, 0), not (0, 0, 0, 1). The result past the records is the same in wave32 and wave64, in two runs each, and with `RESOURCE_LEVEL` 1 (`0x0104dfac`), `OOB_SELECT` 1 (`0x1004dfac`) and FORMAT 74 `32_32_32_FLOAT` (`0x0004afac`). As a control, the same descriptor with `num_records` 6 returns the stored values for indices 3 to 5 (7, 8, 9, 10 / 13, 14, 15, 16 / 19, 20, 21, 22), so the zeros come from the record check, not from memory. gfx1036 is gfx10.3; `docs/dev/HW_ORACLE.md` lists the MUBUF encodings as shared with gfx1013. If you're not already on the fix, I can open a PR that returns zeros past `num_records` instead of throwing.
danzaio commented 2026-10-09 19:27:14 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by danzaio on 2026-10-09T19:27:14Z.


Implementing this now (zeros past num_records per your measurement). Work is on my fork, will hold the branch until intake reopens. Shout if you were already on it.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6087785944 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2241#issuecomment-6087785944). Originally posted by [danzaio](https://github.com/danzaio) on 2026-10-09T19:27:14Z. --- Implementing this now (zeros past num_records per your measurement). Work is on my fork, will hold the branch until intake reopens. Shout if you were already on it.
simonbbby commented 2026-10-09 19:49:09 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by simonbbby on 2026-10-09T19:49:09Z.


I have a fix for this as well: fix/agc-vertex-fetch-past-records, one commit (26df70ea) on main d70b8998. It also applies cleanly to the current main, 8b393b6e. Neither of us can open a PR right now, so it seems worth comparing the two before one gets carried. I built your fix/2241-oob-vertex-fetch (e18e0935) and found two differences that change results.

1. The zero-padded copy goes into the draw-snapshot cache. KeepDrawInput stores it, and ReusableDrawSnapshot gives a vertex snapshot to any later copy at the same address that is no larger. After a draw that reads past num_records, an in-range draw at the same address gets those zeros back.

My branch's execution test, agc_driver_vertex_fetch_past_records, covers this. It draws through a fetch shader over write-watched guest memory, three times:

  • With a 3-record V# from vertex 0, the attribute reads its stored values.
  • With a 3-record V# from vertex 3, the attribute reads zeros.
  • With a 6-record V# from vertex 3, the attribute must read the stored records 3 to 5.

On your branch the third draw reads zeros: an in-range vertex attribute read the zeros of an earlier fetch past num_records at the same address. That happens on an RTX 3090, RADV gfx1036 and llvmpipe, in 2 of 2 runs each. The third draw alone passes. My branch builds these copies outside the cache and passes on all three. On main the test stops at the second draw with this issue's message.

2. OOB_SELECT 2 and 3 don't return zeros past num_records. I measured both with tools/hw-oracle on the same gfx1036 setup, 3-record buffer and 24-byte stride as my measurement above:

  • OOB_SELECT 2 (0x2004dfac): indices 3 to 5 return the stored values (7, 8, 9, 10 / 13, 14, 15, 16 / 19, 20, 21, 22), so the record count isn't checked. With num_records 0, every index returns 0.
  • OOB_SELECT 3 (0x3004dfac): num_records is compared with the byte offset, and the index is ignored. With num_records 3, every index returns 0, index 0 included. With num_records 72, all six indices return the stored values.

Wave32 and wave64 agree, in two runs each. Your branch zero-fills past num_records * stride for every OOB_SELECT. Mine returns zeros for 0 and 1, and still throws past num_records for 2 and 3, since they need a different rule.

Full ctest with the commit on 8b393b6e: RADV and lavapipe 518/518, NVIDIA 517/518 (only #2188).

I'm fine with whichever branch goes forward. If you keep yours, these two points are what I'd change.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6088122938 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2241#issuecomment-6088122938). Originally posted by [simonbbby](https://github.com/simonbbby) on 2026-10-09T19:49:09Z. --- I have a fix for this as well: [`fix/agc-vertex-fetch-past-records`](https://github.com/simonbbby/AnyPS5/tree/fix/agc-vertex-fetch-past-records), one commit (26df70ea) on `main` d70b8998. It also applies cleanly to the current `main`, 8b393b6e. Neither of us can open a PR right now, so it seems worth comparing the two before one gets carried. I built your `fix/2241-oob-vertex-fetch` (e18e0935) and found two differences that change results. **1. The zero-padded copy goes into the draw-snapshot cache.** `KeepDrawInput` stores it, and `ReusableDrawSnapshot` gives a vertex snapshot to any later copy at the same address that is no larger. After a draw that reads past `num_records`, an in-range draw at the same address gets those zeros back. My branch's execution test, `agc_driver_vertex_fetch_past_records`, covers this. It draws through a fetch shader over write-watched guest memory, three times: - With a 3-record V# from vertex 0, the attribute reads its stored values. - With a 3-record V# from vertex 3, the attribute reads zeros. - With a 6-record V# from vertex 3, the attribute must read the stored records 3 to 5. On your branch the third draw reads zeros: `an in-range vertex attribute read the zeros of an earlier fetch past num_records at the same address`. That happens on an RTX 3090, RADV gfx1036 and llvmpipe, in 2 of 2 runs each. The third draw alone passes. My branch builds these copies outside the cache and passes on all three. On `main` the test stops at the second draw with this issue's message. **2. `OOB_SELECT` 2 and 3 don't return zeros past `num_records`.** I measured both with `tools/hw-oracle` on the same gfx1036 setup, 3-record buffer and 24-byte stride as my measurement above: - `OOB_SELECT` 2 (`0x2004dfac`): indices 3 to 5 return the stored values (7, 8, 9, 10 / 13, 14, 15, 16 / 19, 20, 21, 22), so the record count isn't checked. With `num_records` 0, every index returns 0. - `OOB_SELECT` 3 (`0x3004dfac`): `num_records` is compared with the byte offset, and the index is ignored. With `num_records` 3, every index returns 0, index 0 included. With `num_records` 72, all six indices return the stored values. Wave32 and wave64 agree, in two runs each. Your branch zero-fills past `num_records * stride` for every `OOB_SELECT`. Mine returns zeros for 0 and 1, and still throws past `num_records` for 2 and 3, since they need a different rule. Full ctest with the commit on 8b393b6e: RADV and lavapipe 518/518, NVIDIA 517/518 (only #2188). I'm fine with whichever branch goes forward. If you keep yours, these two points are what I'd change.
danzaio commented 2026-10-09 20:40:15 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by danzaio on 2026-10-09T20:40:15Z.


Both fixed on my branch. Out-of-range copies stay out of the snapshot cache now, neither read nor written. OOB_SELECT 2 and 3 keep throwing, each needs its own rule. Your execution test passes here too (RTX 4050, Windows). Thanks for measuring all of this.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6088885439 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2241#issuecomment-6088885439). Originally posted by [danzaio](https://github.com/danzaio) on 2026-10-09T20:40:15Z. --- Both fixed on my branch. Out-of-range copies stay out of the snapshot cache now, neither read nor written. OOB_SELECT 2 and 3 keep throwing, each needs its own rule. Your execution test passes here too (RTX 4050, Windows). Thanks for measuring all of this.
Sign in to join this conversation.
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#2241
No description provided.