Skip to content

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

Merged
adriadam10 merged 2 commits into
boykopovar:mainfrom
lubaxe:fix/agc-null-vertex-buffer-descriptor
Oct 10, 2026
Merged

adriadam10 merged 2 commits into
boykopovar:mainfrom
lubaxe:fix/agc-null-vertex-buffer-descriptor

Conversation

@lubaxe

@lubaxe lubaxe commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

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

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

@fisherjoey

Copy link
Copy Markdown
Contributor

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 f145139 cleanly.

main f145139 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

Copy link
Copy Markdown
Collaborator

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

Copy link
Copy Markdown
Collaborator

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
adriadam10 force-pushed the fix/agc-null-vertex-buffer-descriptor branch from c2cb2b3 to 39d54b2 Compare October 10, 2026 07:03
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 10, 2026
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 10, 2026
lubaxe and others added 2 commits October 10, 2026 09:17
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@adriadam10
adriadam10 force-pushed the fix/agc-null-vertex-buffer-descriptor branch from 39d54b2 to f1c15c2 Compare October 10, 2026 07:23
@adriadam10

Copy link
Copy Markdown
Collaborator

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 github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 10, 2026
@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

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

@adriadam10
adriadam10 merged commit 51b8cef into boykopovar:main Oct 10, 2026
14 checks passed
SleglJan pushed a commit to SleglJan/AnyPS5 that referenced this pull request Oct 10, 2026
…ffer-descriptor

fix(agc): read zero for vertex attributes behind a null V#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants