Skip to content

fix(agc): apply GE_INDX_OFFSET as the base vertex of direct indexed draws - #176

Merged
boykopovar merged 1 commit into
boykopovar:mainfrom
oneandonlydean:fix/agc-indexed-draw-index-offset
Sep 30, 2026
Merged

boykopovar merged 1 commit into
boykopovar:mainfrom
oneandonlydean:fix/agc-indexed-draw-index-offset

Conversation

@oneandonlydean

Copy link
Copy Markdown
Collaborator

What

The GE adds GE_INDX_OFFSET (user config register 0x24a) to every index it fetches. Pm4::ResolveDraw applied it to DRAW_INDEX_AUTO only, so DRAW_INDEX_2 and DRAW_INDEX_OFFSET_2 always fetched from vertex 0, whatever the register held.

Both indexed packets now return the register as the draw's firstVertex, which Draw.cpp already passes to vkCmdDrawIndexed as the vertex offset and adds to the vertex range it copies. Like an auto draw, an indexed draw now throws when the queue state has no GE_INDX_OFFSET; QueueState starts with it at its reset value, 0, so this only fires on a state that dropped it.

On main's mesh path, an indexed draw with a nonzero offset now reaches the existing "mesh draw offsets are unsupported" check instead of drawing without the offset (#133 lifts that check).

In PPSA21564 the title's star field shares one vertex buffer between layers and sets GE_INDX_OFFSET (0xd4d4, 0x11354) for the two layers that start past vertex 65535. Without the offset those layers drew other layers' stars.

Tested

  • Linux (CachyOS, RTX 4090): agc_driver_pm4 (testIndexedDraw) resolves DRAW_INDEX_OFFSET_2 and DRAW_INDEX_2 with the register at 0 and at 0xd4d4 and checks the base vertex, and checks that a state without the register throws. On main it fails with "DRAW_INDEX_OFFSET_2 ignored GE_INDX_OFFSET".
  • Exercised in PPSA21564 on our integration branch: the star field's upper layers draw their own stars.
  • ctest: 64/64 pass. agc_driver_recorder_tests passes. agc_driver_graphics_tests passes on a throwaway merge with test(agc): link agc_driver_graphics_tests again, run it under ctest and bring its stale expectations up to date #113 (which links it again).

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
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

…raws

The GE adds GE_INDX_OFFSET to every index it fetches. The driver applied
it to auto draws only, so DRAW_INDEX_2 and DRAW_INDEX_OFFSET_2 fetched
from vertex 0 whatever the register held. Both packets now take it as
their base vertex, and like an auto draw they refuse a queue state without
the register (its reset value, 0, is part of the initial state).
@github-actions github-actions Bot added the agc libSceAgc* label Sep 30, 2026
@boykopovar
boykopovar merged commit 52ab9e3 into boykopovar:main Sep 30, 2026
3 checks passed
oneandonlydean added a commit to oneandonlydean/AnyPS5 that referenced this pull request Oct 1, 2026
…opovar#208 test layout, our merged PRs) into astrobot

Conflicts resolved:
- Driver.cpp: upstream split it into Execution/src/Driver/*; astrobot's
  driver changes are ported into the split files (flip throttle
  APS5_MAX_QUEUED_FLIPS, dispatch tolerance, NoteProgram, metadata-pass
  switch and DB HTILE blits, depth state in the draw register key, HTILE
  fill clears, wait outcome counters, opt-in deferred EOP interrupts).
  boykopovar#192's KnownDrawRejection is taken.
- Our merged PRs take upstream's reviewed versions: boykopovar#124 shader fusion,
  boykopovar#128 videoout open param, boykopovar#132 CB metadata passes, boykopovar#138 EOP events,
  boykopovar#176 GE_INDX_OFFSET, boykopovar#136/boykopovar#137 pixel inputs and NoPerspective by I/J
  pair, boykopovar#133 mesh tests. boykopovar#142's interpolation validation is upstream's.
- Depth: astrobot's DepthTarget model stays; upstream's DepthSurface
  module is dropped again, boykopovar#188's 16-bit depth-bit reads are kept on top.
- Videodec2: upstream's ffmpeg-core version (boykopovar#42 rework); 3rdparty/FFmpeg
  stays for libSceAvPlayer only.
- Tests follow boykopovar#208's layout (add_test_executable, build/tests); the
  AvPlayer, GDS and wave tests are defined the same way.
- Shader disk cache format 5 and request serialization version 7 cover
  both sides' fields.
- Duplicates the auto-merge produced (state decoders, RequestInputInfo,
  structurizer helpers, image offsets, opcode enum, tests) are removed.
@oneandonlydean
oneandonlydean deleted the fix/agc-indexed-draw-index-offset branch October 1, 2026 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants