Skip to content

fix(agc): exclude skipped vertex records from target alias checks - #4408

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
santhoshkumar-dev:codex/agc-render-target-vertex-aliasing
Oct 13, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
santhoshkumar-dev:codex/agc-render-target-vertex-aliasing

Conversation

@santhoshkumar-dev

@santhoshkumar-dev santhoshkumar-dev commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

What

Direct vertex inputs treat every byte from the descriptor base through the last fetch as live. With stride 16 and firstVertex 4096, a target in the skipped first 64 KiB incorrectly causes vertex buffer aliases the render target, although the three vertices read only bytes 65536 through 65583.

Use the first vertex or first instance to bound the alias check. Indexed draws retain index zero as a conservative lower bound before adding the base vertex; indirect draws retain the full descriptor extent. Copy planning and buffer-binding origins stay unchanged. Actual vertex/target overlap, zero-stride overlap, and the existing index/shader-buffer alias checks remain rejected.

The existing flush hook orders pending GPU writes, storage-image writeback and shadow publication before a copied snapshot or imported vertex input. Same-draw overlapping-byte console ordering remains unverified and unsupported, as recorded in the AGC technical debt file.

Rebased onto main ad653c9 (PR head 4462322). The technical debt entry now uses the upstream split layout.

Related to #4369, but this PR does not claim to fix Slay the Princess. The reporter identified intermittent 0xff000000 index data with firstVertex 0, a separate cause from the skipped-prefix false positive. Later, plain main ffa1984 also completed three 150-second control runs without the abort, so the earlier apparent improvement with #1359 was withdrawn. The latest maintainer request is for three more current-main runs and closure if clean.

Tested

Local revalidation after the rebase: Windows 11 Pro 10.0.26200, MinGW-w64 GCC 15.2.0, Release, RX 6700 XT, driver 32.0.21045.5002, full CMake configuration with BUILD_TESTING=ON. Affected runtime and recorder, graphics, vertex-fetch and zero-stride test targets built. No title dump used.

  • 26/26 focused CTest tests passed, no skips, 9.79 s. Vulkan execution was required with ANYPS5_REQUIRE_VULKAN=1. No global APS5_NO_PIPELINE_LTO override was applied.
  • Includes both new agc_driver_vertex_target_range_copied and agc_driver_vertex_target_range_imported, agc_driver_graphics, both vertex-fetch tests, pipeline cache/library tests, in-place draw inputs, snapshots, shadow publication, host-import lifetime and storage-buffer ordering.
  • The regressions consume vertex data from a pending RGBA32F color draw. Pixel readback checks offsets of 0.5 and then 0.75, including a draw-recipe hit. Vertex/instance offsets, indexed draws, disjoint descriptors and rejection of real, zero-stride, indirect and index aliases are covered.
  • Fresh negative control on main ad653c9: keeping the regression fixtures but restoring only main's Draw.cpp makes both range regressions fail with vertex buffer aliases the render target (0/2, 0.61 s). Rebuilding with the PR's Draw.cpp restored makes both pass again. The prior default-setting AMD crashes in pipeline cache/library and vertex-fetch tests were not observed in this focused rerun on the rebased tree.
  • Conventions, diff whitespace and test registration checks pass. tools/pr_overlap.py logic, excluding this PR, found no overlap with other open pull requests.
  • The full repository suite, Linux and console hardware were not run locally.

Independent reports on the original head:

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 under Silent stubs in their library's technical debt file
  • 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 (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • AI-assisted: yes, OpenAI Codex

@santhoshkumar-dev

Copy link
Copy Markdown
Contributor Author

@xXPBSXx Could you test this branch with Slay the Princess and check whether it gets past the vertex buffer aliases the render target failure reported in #4369?

The fix covers a verified false positive where the alias check includes an unused vertex-buffer prefix skipped by firstVertex or firstInstance. Both synthetic GPU regressions pass, but we haven't confirmed that your failing draw has the same cause. Please let us know whether the original error still occurs and whether you encounter a different failure afterward.

@xXPBSXx

xXPBSXx commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

@santhoshkumar-dev you asked for a Slay the Princess run. Result first: it does not get past vertex buffer aliases the render target with this PR, and I think the cause is different from the skipped prefix.

Tree and tests: this PR (clean merge) on main e7c70a2 + #3840 (needed by this title for fcntl), Windows 10, MinGW GCC, Release, RTX 4080 SUPER. agc_driver_vertex_target_range_copied and ..._imported pass, and so does agc_driver_graphics (3/3 ctest, 13.4 s).

Title: PPSA24423 relinked from its decrypted ELF, 0 absent imports; it runs about 79 s and ends with the same what(): AGC graphics: vertex buffer aliases the render target.

Why it does not apply here (details and a local diagnostic that prints the draw, on #4369): the failing draw is an indexed draw of 6 32-bit indices read from 0x39a418000, and all six are 0xff000000. The vertex V# is sane (848c8000 00080003 00000004 0004022c, 4 records, stride 8) and the draw has firstVertex 0, but the highest index 0xff000000 times stride 8 makes the range 0x7f8000008 bytes (about 32 GiB), which covers the 1080p color target at 0x385c30000. So the range is wrong because of the index data, not because of an unused prefix; this PR keeps index 0 as the lower bound for indexed draws, so the overlap stays. I do not know yet why the index memory holds 0xff000000 (my guess so far is data written too late or a clear that reached it); that is on #4369.

AI-assisted (Claude Code).

@LeandroLP23

Copy link
Copy Markdown
Contributor

Ran this on AMD hardware, since the GPU tests in CI only use lavapipe: Windows 11 (26300), AMD Radeon 860M (RDNA 3.5, driver 32.0.13058.8001), WinLibs GCC 15.2.0, Release, BUILD_TESTING=ON. Head 8097648f9 merged onto main f8dee0595, together with #4445: on this GPU, main crashes 47 agc_ tests inside amdvlk64.dll without it (#4435), which would hide anything else.

  • ctest -R '^agc_' -j 1: 437/437.
  • ctest -E '^agc_' -j 4: 530/530.
  • agc_driver_vertex_target_range_copied and agc_driver_vertex_target_range_imported: 3/3.
  • With main's Draw.cpp restored, both of those fail.

I don't have Slay the Princess, so this doesn't cover the title.

AI-assisted: yes (Claude Code)

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 12, 2026
@santhoshkumar-dev
santhoshkumar-dev force-pushed the codex/agc-render-target-vertex-aliasing branch from 8097648 to e421743 Compare October 13, 2026 08:11
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 13, 2026
@santhoshkumar-dev
santhoshkumar-dev force-pushed the codex/agc-render-target-vertex-aliasing branch from e421743 to 4462322 Compare October 13, 2026 08:35
@santhoshkumar-dev
santhoshkumar-dev marked this pull request as ready for review October 13, 2026 08:37
@santhoshkumar-dev

Copy link
Copy Markdown
Contributor Author

Marked ready for review at 4462322, rebased onto main ad653c9. Before doing so I checked this PR's comments/reviews, its six cross-referenced threads (#4369, #1359, #4073, #3709, #419 and #4411), and repository issue/PR and discussion searches. There are no outstanding inline review requests.

Updated and verified

  • Rebased the existing range correction without changing its implementation or adding another topic. Migrated its debt entry using feat(tools): keep technical debt in one file per library #4411's split layout and removed the outdated statement that the reported draw details were unavailable. The PR description now separates the generic regression from title reports.
  • Rebuilt the affected runtime and recorder/graphics/vertex-fetch test targets on Windows 11 Pro 10.0.26200, GCC 15.2.0, Release, RX 6700 XT (driver 32.0.21045.5002).
  • 26/26 focused CTests pass, no skips, 9.79 s, with Vulkan execution required and no global APS5_NO_PIPELINE_LTO override. This includes both copied/imported regressions, graphics validation, pipeline cache/library, vertex fetch, zero-stride fetch, draw-input/snapshot, shadow, import-lifetime and storage-ordering checks.
  • Repeated the negative control on today's base, keeping the fixtures and replacing only production Draw.cpp:
Production Draw.cpp Copied regression Imported regression
main ad653c9 Fails: vertex buffer aliases the render target Fails: same alias error
PR version restored and rebuilt Passes Passes
  • Conventions, whitespace and test-registration checks pass; the refreshed overlap check finds no overlap with other open PRs. The worktree is clean. The earlier NVIDIA and AMD reports also support the synthetic regression, but their results belong to their stated older heads/integration stacks.

What the other reports establish

Still unchanged or unverified

The fix only excludes an unused prefix from the alias test. Copy/binding origins and real-overlap rejection remain unchanged. Same-draw reads of active target bytes remain unsupported, and console ordering is unverified. No title-specific workaround, index-data/CPU-write ordering fix or new dependency was added. Depends on: none and Unblocks: none remain accurate. No local title run, full repository suite, Linux run or console-hardware result is claimed.

Full CI request

Could a collaborator with upstream write access run the Build workflow for this revision? Full Linux/Windows tests and the relinker matrix are still pending; the automatic PR checks do not run them. This account cannot dispatch the upstream workflow under the repository's access rule.

gh workflow run build.yml --repo boykopovar/AnyPS5 --ref main --field pr=4408

AI-assisted: OpenAI Codex.

@adriadam10

Copy link
Copy Markdown
Collaborator

Checked on current main: both new agc_driver_vertex_target_range_* tests pass and fail with Draw.cpp reverted; agc_driver_graphics passes. Indexed draws keep index 0 as the lower bound, indirect draws the full extent, so real, zero-stride and index aliases are still rejected. agc_driver_tessellation segfaults here with and without this change. Merging once the full Build is green.

@adriadam10
adriadam10 merged commit 80e70b4 into boykopovar:main Oct 13, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants