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

Merged
santhoshkumar-dev merged 1 commit from upstream-pr/4408 into main 2026-10-13 14:29:52 +00:00
santhoshkumar-dev commented 2026-10-12 09:44:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by santhoshkumar-dev on 2026-10-12T09:44:39Z.


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 ad653c9bc (PR head 44623222c). 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 ffa198407 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 ad653c9bc: 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:

  • NVIDIA RTX 4080 SUPER: both range regressions and graphics passed; Slay the Princess still encountered its separate index-data failure on that older tree.
  • AMD Radeon 860M: 437/437 AGC tests and 530/530 other tests passed with the then-required #4445, now merged into main. Restoring main's Draw.cpp made both range regressions fail. No title run was performed.

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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4827653335 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4408). Originally posted by [santhoshkumar-dev](https://github.com/santhoshkumar-dev) on 2026-10-12T09:44:39Z. --- ### 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` ad653c9bc (PR head 44623222c). 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` ffa198407 also completed three 150-second control runs without the abort, so the earlier apparent improvement with #1359 was withdrawn. The [latest maintainer request](https://github.com/boykopovar/AnyPS5/issues/4369#issuecomment-6136640712) 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 ad653c9bc: 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: - [NVIDIA RTX 4080 SUPER](https://github.com/boykopovar/AnyPS5/pull/4408#issuecomment-6122848860): both range regressions and graphics passed; Slay the Princess still encountered its separate index-data failure on that older tree. - [AMD Radeon 860M](https://github.com/boykopovar/AnyPS5/pull/4408#issuecomment-6125046327): 437/437 AGC tests and 530/530 other tests passed with the then-required #4445, now merged into main. Restoring main's Draw.cpp made both range regressions fail. No title run was performed. ### 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 under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [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 (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] AI-assisted: yes, OpenAI Codex
santhoshkumar-dev commented 2026-10-12 09:49:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by santhoshkumar-dev on 2026-10-12T09:49:58Z.


@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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6121825766 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4408#issuecomment-6121825766). Originally posted by [santhoshkumar-dev](https://github.com/santhoshkumar-dev) on 2026-10-12T09:49:58Z. --- @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 commented 2026-10-12 10:54:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-12T10:54:54Z.


@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 e7c70a2df + #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).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6122848860 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4408#issuecomment-6122848860). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-12T10:54:54Z. --- @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` e7c70a2df + #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 commented 2026-10-12 13:16:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-12T13:16:26Z.


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)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6125046327 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4408#issuecomment-6125046327). Originally posted by [LeandroLP23](https://github.com/LeandroLP23) on 2026-10-12T13:16:26Z. --- 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)
santhoshkumar-dev commented 2026-10-13 08:37:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by santhoshkumar-dev on 2026-10-13T08:37:32Z.


Marked ready for review at 44623222c, rebased onto main ad653c9bc. 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 #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 ad653c9bc 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

  • Slay the Princess / #4369: intermittent 0xff000000 indices with firstVertex 0 are a different cause from a skipped descriptor prefix. This PR did not fix that failure on the tested older tree. The proposed benefit from #1359 was withdrawn after the same-main control also passed. The maintainer's request remains three more current-main runs, closing #4369 if clean; no causal title-fix claim is made here.
  • Kena / #4073 and Puyo Puyo Tetris 2 / #3709: the mixed-stack mentions of #4408 still hit their existing null-read and compute-program/descriptor stops. Neither establishes a fix or a regression caused by #4408.
  • New Joe & Mac on #419: a mixed stack reached the 240-second limit without a stop. The report credits upstream custom sample-location changes (#2169/#4309), and the image was not checked. This is not evidence of a title unblocked by #4408.

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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6141658521 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4408#issuecomment-6141658521). Originally posted by [santhoshkumar-dev](https://github.com/santhoshkumar-dev) on 2026-10-13T08:37:32Z. --- Marked ready for review at **44623222c**, rebased onto `main` **ad653c9bc**. 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 #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` ad653c9bc | 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** - [Slay the Princess / #4369](https://github.com/boykopovar/AnyPS5/issues/4369#issuecomment-6123050698): intermittent `0xff000000` indices with firstVertex 0 are a different cause from a skipped descriptor prefix. This PR did not fix that failure on the tested older tree. The proposed benefit from #1359 was [withdrawn after the same-main control also passed](https://github.com/boykopovar/AnyPS5/pull/1359#issuecomment-6124330001). The maintainer's request remains three more current-main runs, closing #4369 if clean; no causal title-fix claim is made here. - [Kena / #4073](https://github.com/boykopovar/AnyPS5/issues/4073#issuecomment-6123250896) and [Puyo Puyo Tetris 2 / #3709](https://github.com/boykopovar/AnyPS5/issues/3709#issuecomment-6123710291): the mixed-stack mentions of #4408 still hit their existing null-read and compute-program/descriptor stops. Neither establishes a fix or a regression caused by #4408. - [New Joe & Mac on #419](https://github.com/boykopovar/AnyPS5/pull/419#issuecomment-6123709525): a mixed stack reached the 240-second limit without a stop. The report credits upstream custom sample-location changes (#2169/#4309), and the image was not checked. This is not evidence of a title unblocked by #4408. **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. ```sh gh workflow run build.yml --repo boykopovar/AnyPS5 --ref main --field pr=4408 ``` AI-assisted: OpenAI Codex.
adriadam10 commented 2026-10-13 14:15:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T14:15:29Z.


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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6147585257 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4408#issuecomment-6147585257). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-13T14:15:29Z. --- 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.
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!4408
No description provided.