fix(agc): read zero for vertex attributes behind a null V# #1969

Merged
lubaxe merged 2 commits from upstream-pr/1969 into main 2026-10-10 07:28:07 +00:00
lubaxe commented 2026-10-09 03:26:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by lubaxe on 2026-10-09T03:26:02Z.


What

A vertex attribute whose V# is all zero has no address, no records and no format. Its DST_SEL fields are 0, which selects 0, so on hardware every fetch through it reads 0. DecodeVertexFormat threw unsupported vertex format 0 for it, which stopped PPSA12544 after its intro.

  • NullVertexDescriptor recognizes the all-zero V#. DecodeVertexFormat gives it an R32 float format of the attribute's component count.
  • VertexBufferReadSize and VertexBufferExtent return that format's size (at most 16 bytes) instead of a guest range.
  • The draw does not copy guest memory for such an attribute. It binds the new zeroVertexBuffer: 16 zeroed bytes created with the device, next to emptyBuffer. The layout gives the attribute stride 0.
  • A V# with an address and format 0 still throws.
  • The behaviour follows the RDNA2 ISA and is not measured on hardware, so it is recorded in TechnicalDebt.md (Functional).

Tested

  • Windows 11 Pro, RTX 5090, WinLibs GCC 15.2.0 r7, Release.
  • New nullVertexDescriptorTests in agc_driver_graphics: 1 to 4 components, sizes within the zero buffer, and format 0 with an address still rejected. Without the decoder change it fails with unsupported vertex format 0.
  • ctest: 487 of 488 passed. The failure is agc_driver_pixel_lds, which also fails on unmodified main on this GPU.
  • agc_driver_recorder_tests, run directly: passed.
  • PPSA12544 (Hollow Knight: Silksong) with #846 and #425: the title gets past the draw that threw and reaches gameplay in tut_01. With eager write-back the scene renders correctly. Its lazy write-back problem is separate (#1970).
  • tools/check_conventions.py --base origin/main passes.

Conflicts with #1968 only in tests/Graphics.cpp, where both add a test at the same place. I'll rebase whichever merges second.

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:4795587531 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1969). Originally posted by [lubaxe](https://github.com/lubaxe) on 2026-10-09T03:26:02Z. --- ### What A vertex attribute whose V# is all zero has no address, no records and no format. Its `DST_SEL` fields are 0, which selects 0, so on hardware every fetch through it reads 0. `DecodeVertexFormat` threw `unsupported vertex format 0` for it, which stopped PPSA12544 after its intro. - `NullVertexDescriptor` recognizes the all-zero V#. `DecodeVertexFormat` gives it an R32 float format of the attribute's component count. - `VertexBufferReadSize` and `VertexBufferExtent` return that format's size (at most 16 bytes) instead of a guest range. - The draw does not copy guest memory for such an attribute. It binds the new `zeroVertexBuffer`: 16 zeroed bytes created with the device, next to `emptyBuffer`. The layout gives the attribute stride 0. - A V# with an address and format 0 still throws. - The behaviour follows the RDNA2 ISA and is not measured on hardware, so it is recorded in `TechnicalDebt.md` (Functional). ### Tested - Windows 11 Pro, RTX 5090, WinLibs GCC 15.2.0 r7, Release. - New `nullVertexDescriptorTests` in `agc_driver_graphics`: 1 to 4 components, sizes within the zero buffer, and format 0 with an address still rejected. Without the decoder change it fails with `unsupported vertex format 0`. - `ctest`: 487 of 488 passed. The failure is `agc_driver_pixel_lds`, which also fails on unmodified `main` on this GPU. - `agc_driver_recorder_tests`, run directly: passed. - PPSA12544 (Hollow Knight: Silksong) with #846 and #425: the title gets past the draw that threw and reaches gameplay in `tut_01`. With eager write-back the scene renders correctly. Its lazy write-back problem is separate (#1970). - `tools/check_conventions.py --base origin/main` passes. Conflicts with #1968 only in `tests/Graphics.cpp`, where both add a test at the same place. I'll rebase whichever merges second. ### 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)
fisherjoey commented 2026-10-09 04:36:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-09T04:36:42Z.


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 onto main f1451396 cleanly.

main f1451396 main + this PR
RTX 5070 Ti, driver 595.91.07, ctest -R agc_driver -j1 207 / 207 207 / 207
RADV, Ryzen 5 7600X iGPU (gfx1036), Mesa 26.2.1, same 207 / 207 207 / 207
CPU tests (-E agc_driver) 286 / 287 286 / 287

The CPU failure is guest_dynamic_loader, which fails the same way on main.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6074353873 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1969#issuecomment-6074353873). Originally posted by [fisherjoey](https://github.com/fisherjoey) on 2026-10-09T04:36:42Z. --- 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 onto `main` f1451396 cleanly. | | `main` f1451396 | `main` + this PR | |---|---|---| | RTX 5070 Ti, driver 595.91.07, `ctest -R agc_driver -j1` | 207 / 207 | 207 / 207 | | RADV, Ryzen 5 7600X iGPU (gfx1036), Mesa 26.2.1, same | 207 / 207 | 207 / 207 | | CPU tests (`-E agc_driver`) | 286 / 287 | 286 / 287 | The CPU failure is `guest_dynamic_loader`, which fails the same way on `main`.
oneandonlydean commented 2026-10-10 05:17:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-10T05:17:22Z.


This conflicts with main again after today's merges (Draw.cpp, tests/Graphics.cpp, TechnicalDebt.md); could you rebase? It passed testing and is otherwise ready.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6094133309 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1969#issuecomment-6094133309). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-10T05:17:22Z. --- This conflicts with main again after today's merges (`Draw.cpp`, `tests/Graphics.cpp`, `TechnicalDebt.md`); could you rebase? It passed testing and is otherwise ready.
adriadam10 commented 2026-10-10 07:03:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T07:03:21Z.


Rebased onto current main (conflicts in Draw.cpp, tests/Graphics.cpp, TechnicalDebt.md) as requested.

  • main now zeroes out-of-range vertex fetches per attribute (zeroed[] / zeroVertexBuffer(context, attribute)), so a null V# goes through that branch (NullVertexDescriptor(attribute) || VertexFetchOutOfRange(attribute)). The device-wide Context::zeroVertexBuffer is dropped as redundant.
  • Removed the EmptyBufferBytes check from the new test (the buffer is now sized to the attribute); TechnicalDebt wording adjusted.
    Rebuilt, libSceAgcDriver ctest 303/303, conventions check passes. Merging on green CI.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6094926754 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1969#issuecomment-6094926754). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-10T07:03:21Z. --- Rebased onto current `main` (conflicts in `Draw.cpp`, `tests/Graphics.cpp`, `TechnicalDebt.md`) as requested. - `main` now zeroes out-of-range vertex fetches per attribute (`zeroed[]` / `zeroVertexBuffer(context, attribute)`), so a null V# goes through that branch (`NullVertexDescriptor(attribute) || VertexFetchOutOfRange(attribute)`). The device-wide `Context::zeroVertexBuffer` is dropped as redundant. - Removed the `EmptyBufferBytes` check from the new test (the buffer is now sized to the attribute); TechnicalDebt wording adjusted. Rebuilt, libSceAgcDriver ctest 303/303, conventions check passes. Merging on green CI.
adriadam10 commented 2026-10-10 07:23:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T07:23:01Z.


Rebased onto current main again (conflict in tests/Graphics.cpp, next to the new storeAtFlipTests; both kept). Also dropped the stale EmptyBufferBytes check from the new test, since the zero buffer is sized to the attribute now.
Rebuilt, libSceAgcDriver ctest 304/304. Merging on green CI.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6095081843 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1969#issuecomment-6095081843). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-10T07:23:01Z. --- Rebased onto current `main` again (conflict in `tests/Graphics.cpp`, next to the new `storeAtFlipTests`; both kept). Also dropped the stale `EmptyBufferBytes` check from the new test, since the zero buffer is sized to the attribute now. Rebuilt, libSceAgcDriver ctest 304/304. Merging on green CI.
github-actions[bot] commented 2026-10-10 07:25:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T07:25:36Z.


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
#1619 docs/dev/TechnicalDebt.md L426
#1819 docs/dev/TechnicalDebt.md L426
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6095100749 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1969#issuecomment-6095100749). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-10T07:25:36Z. --- <!-- 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 | |---|---|---|---| | #1619 | `docs/dev/TechnicalDebt.md` [L426](https://github.com/boykopovar/AnyPS5/blob/d99babe24c5138e4ca822a7ee8c45f534a6c7f10/docs/dev/TechnicalDebt.md#L426) | | | | #1819 | `docs/dev/TechnicalDebt.md` [L426](https://github.com/boykopovar/AnyPS5/blob/d99babe24c5138e4ca822a7ee8c45f534a6c7f10/docs/dev/TechnicalDebt.md#L426) | | |
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!1969
No description provided.