fix(agc): take an indexed draw's base vertex as signed #26036

Open
birdmarty wants to merge 3 commits from upstream-pr/26036 into main
birdmarty commented 2026-11-23 04:53:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by birdmarty on 2026-11-23T04:53:47Z.


What

An indexed draw whose base vertex is negative threw indexed draw vertex range overflow. The base vertex is added to every index, and a negative one is valid as long as the lowest index plus it is not below 0: the hardware's base vertex and Vulkan's vertexOffset are signed. Draw required firstVertex <= UINT32_MAX - maxIndex, which reads -532 as 0xfffffdec. The adds after that check (minIndex += firstVertex, maxIndex += firstVertex) already wrap to the right vertices, and vkCmdDrawIndexed already gets the offset as int32_t.

The indexed range check now takes the offset as signed: the lowest index plus the offset must be at least 0, and the highest index plus the offset at most UINT32_MAX. The expanded-index path (quad lists and emulated strips) now tracks its lowest index and checks both bounds the same way. Two places used the offset as unsigned as well, and now take it as signed:

  • the zero-fetch index limit (zeroFrom - firstVertex), where a negative offset gave 0;
  • the render-target alias check, which now measures from the lowest vertex the indexed draw reads (minIndex) instead of the offset.

The vertex offset of an indexed draw can also come from two words: GE_INDX_OFFSET and a vertex shader's base-vertex user SGPR, which Driver::FoldDrawOffsets adds into the draw. That add used an unsigned overflow test, so +3 and -3, a final offset of 0, threw draw vertex offset overflow. For an indexed draw the two words are now added as signed 32-bit values, and only a total outside the signed 32-bit range is refused. The in-place index path behind a pending GPU writer (InPlaceIndexBehindWriter, opt-in through APS5_INDEX_IN_PLACE_BEHIND_WRITER) compared the offset as unsigned too: a large negative offset with 16-bit indices, such as -2147483648, was bound in place with its lowest index taken as 0, and the range check then refused the draw. A negative offset now stays on the copy path, which measures the real index range.

Non-indexed draws are unchanged: their first vertex is an unsigned start.

Changes

  • core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp: the range checks above and the in-place index path.
  • core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/IndirectDraw.cpp: the signed fold in FoldDrawOffsets.
  • core/libs/prx/libSceAgcDriver/tests/execution/DrawOffsetIndices.cpp (run by agc_driver_draw_offset_indices, _poisoned and _poisoned_in_place): a direct indexed draw with base vertex -3 over the indices 5, 3, 4 fetches vertices 2, 0 and 1 for both instances; GE_INDX_OFFSET +3 with s16 -3, and -3 with +3, over the indices 2, 0, 1 fetch vertices 2, 0 and 1; GE_INDX_OFFSET 0x7fffffff with s16 1, and 0x80000000 with s16 -1, are refused with draw vertex offset overflow; an indexed quad-list draw with base vertex -3 over the indices 0, 1, 2, 2 is refused with indexed draw vertex range overflow.
  • core/libs/prx/libSceAgcDriver/tests/Recorder.cpp (agc_index_in_place_behind_writer): 16-bit index ranges with the offsets -3 and -2147483648 stay on the copy path; the case that may bind in place now uses 0x7fffffff instead of 0xffff0000, which is -65536 as a signed offset.

No debt entry changes: the change closes no recorded gap and adds none.

Tested

Windows 11 Pro (build 26300), Intel Core i9-9900K, AMD Radeon RX 6800 (AMD driver 26.10.1, Windows driver 32.0.21045.16010, Vulkan 1.4.315), MinGW-w64 GCC 15.3.0, Release, main 441fa65119.

Focused set (agc_driver_graphics, agc_shader_memory, agc_driver_recorder, agc_driver_draw*, agc_driver_*vertex*, agc_driver_*index*, agc_driver_list_restart*, agc_driver_zero_stride*, agc_driver_relative*, agc_driver_mesh*, agc_driver_stencil_replay*, agc_embedded_vertex*, agc_driver_indirect*, agc_index_*, agc_driver_pm4*) with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (1.4.363) and VK_LOADER_DEBUG=layer:

main 441fa65119 this change (8a0fcdd825)
Passed / failed 171 / 0 171 / 0
Validation layer inserted 223 223
VUID- lines 0 0

Rebased onto origin/main 0af6efad52 as 6080bb0b93 (resolving conflicts with merged #26775 by preserving !wholeRange on firstByte in Draw.cpp and the 5-argument attempt(...) signature in tests/Recorder.cpp). Re-verified on the same RX 6800 with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (1.4.363.0), VK_LOADER_DEBUG=layer:

  • Focused 20-test set (agc_driver_draw_offset_indices*, agc_index_in_place_behind_writer, agc_driver_graphics, agc_driver_list_restart*, agc_driver_indirect*, agc_driver_zero_stride*, agc_driver_recorder): 20 / 20 passed on both origin/main 0af6efad52 and 6080bb0b93, 34 validation layer inserts on both, 0 VUID- lines.
  • Negative control (checking out origin/main 0af6efad52's Draw.cpp and IndirectDraw.cpp against 6080bb0b93's tests): 4 / 4 failed (agc_driver_draw_offset_indices, _poisoned, _poisoned_in_place with AGC driver: draw vertex offset overflow, and agc_index_in_place_behind_writer on the -2147483648 case); all 4 pass on 6080bb0b93.
  • Earlier 171-test full sweep on 441fa65119 / 8a0fcdd825 above; tools/check_conventions.py --base origin/main and tools/debt_fold.py --check pass on 6080bb0b93.

Forza Horizon 5 (PPSA22327 01.685.672), local stack of open PRs:

  • What the game does: an indexed triangle-list draw with 16-bit indices from 0x214 to 0x1698 and a base vertex of 0xfffffdec (-532), so it reads vertices 0 to 0x1484.
  • Without this change: the refusal stopped 3 runs, at 252.7 s, 261.1 s and 259.9 s.
  • With this change: 3 runs on d85e9ac04d, none with it. All three ran 610 s, past the point where it stopped, to a later, unrelated freeze. 4f888baf4a, 8a0fcdd825 and rebased 6080bb0b93 were not run in the game.

py -3 tools/check_conventions.py --base origin/main and py -3 tools/debt_fold.py --check pass. py -3 tools/pr_overlap.py --branch fix/agc-negative-base-vertex (2,508 open PRs): all 83 mergeable PRs that share files merge cleanly. The 45 PRs that conflict with main were searched by hand; #9897 and #14032 set draw.firstVertex in tests, #10193, #13928 and #22647 change where the zero-fetch vertex attributes come from, and #22647 calls FoldDrawOffsets; none takes the base vertex as signed or changes the fold or the in-place index check.

Not tested: a negative base vertex through an indirect draw's arguments in a title, the expanded-index path with a negative base vertex in a title, other GPUs, Linux.

Part of the Forza Horizon 5 (PPSA22327) bring-up, #25152. It was found on the stack of PRs the game needed (#24960, #24994, #25151, #25867–#25874, #26034 and #26035 are now merged; #23688, #23545, #21479, #11825, #23778, #21155, #22306 and #21199) and stands alone: it applies to main by itself and needs none of them to build or pass its tests.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: PPSA22327 #25152
  • GPUs tested: AMD Radeon RX 6800 (vendor=0x1002, device=0x73bf), AMD proprietary driver 26.10.1 (Windows driver 32.0.21045.16010, Vulkan 1.4.315), Windows 11 Pro (build 26300); Khronos validation layer 1.4.363.0 on main and this change, 0 VUIDs
  • AI-assisted: yes

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Corrected vertex-offset handling for indexed draws, including negative offsets and values near the supported range limits.
    • Improved validation of indexed-draw vertex ranges to prevent invalid or overflowing ranges from being accepted.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5447332826 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26036). Originally posted by [birdmarty](https://github.com/birdmarty) on 2026-11-23T04:53:47Z. --- ### What An indexed draw whose base vertex is negative threw `indexed draw vertex range overflow`. The base vertex is added to every index, and a negative one is valid as long as the lowest index plus it is not below 0: the hardware's base vertex and Vulkan's `vertexOffset` are signed. `Draw` required `firstVertex <= UINT32_MAX - maxIndex`, which reads -532 as 0xfffffdec. The adds after that check (`minIndex += firstVertex`, `maxIndex += firstVertex`) already wrap to the right vertices, and `vkCmdDrawIndexed` already gets the offset as `int32_t`. The indexed range check now takes the offset as signed: the lowest index plus the offset must be at least 0, and the highest index plus the offset at most UINT32_MAX. The expanded-index path (quad lists and emulated strips) now tracks its lowest index and checks both bounds the same way. Two places used the offset as unsigned as well, and now take it as signed: - the zero-fetch index limit (`zeroFrom - firstVertex`), where a negative offset gave 0; - the render-target alias check, which now measures from the lowest vertex the indexed draw reads (`minIndex`) instead of the offset. The vertex offset of an indexed draw can also come from two words: GE_INDX_OFFSET and a vertex shader's base-vertex user SGPR, which `Driver::FoldDrawOffsets` adds into the draw. That add used an unsigned overflow test, so +3 and -3, a final offset of 0, threw `draw vertex offset overflow`. For an indexed draw the two words are now added as signed 32-bit values, and only a total outside the signed 32-bit range is refused. The in-place index path behind a pending GPU writer (`InPlaceIndexBehindWriter`, opt-in through `APS5_INDEX_IN_PLACE_BEHIND_WRITER`) compared the offset as unsigned too: a large negative offset with 16-bit indices, such as -2147483648, was bound in place with its lowest index taken as 0, and the range check then refused the draw. A negative offset now stays on the copy path, which measures the real index range. Non-indexed draws are unchanged: their first vertex is an unsigned start. #### Changes - `core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp`: the range checks above and the in-place index path. - `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/IndirectDraw.cpp`: the signed fold in `FoldDrawOffsets`. - `core/libs/prx/libSceAgcDriver/tests/execution/DrawOffsetIndices.cpp` (run by `agc_driver_draw_offset_indices`, `_poisoned` and `_poisoned_in_place`): a direct indexed draw with base vertex -3 over the indices 5, 3, 4 fetches vertices 2, 0 and 1 for both instances; GE_INDX_OFFSET +3 with s16 -3, and -3 with +3, over the indices 2, 0, 1 fetch vertices 2, 0 and 1; GE_INDX_OFFSET 0x7fffffff with s16 1, and 0x80000000 with s16 -1, are refused with `draw vertex offset overflow`; an indexed quad-list draw with base vertex -3 over the indices 0, 1, 2, 2 is refused with `indexed draw vertex range overflow`. - `core/libs/prx/libSceAgcDriver/tests/Recorder.cpp` (`agc_index_in_place_behind_writer`): 16-bit index ranges with the offsets -3 and -2147483648 stay on the copy path; the case that may bind in place now uses 0x7fffffff instead of 0xffff0000, which is -65536 as a signed offset. No debt entry changes: the change closes no recorded gap and adds none. ### Tested Windows 11 Pro (build 26300), Intel Core i9-9900K, AMD Radeon RX 6800 (AMD driver 26.10.1, Windows driver 32.0.21045.16010, Vulkan 1.4.315), MinGW-w64 GCC 15.3.0, Release, `main` 441fa65119. Focused set (`agc_driver_graphics`, `agc_shader_memory`, `agc_driver_recorder`, `agc_driver_draw*`, `agc_driver_*vertex*`, `agc_driver_*index*`, `agc_driver_list_restart*`, `agc_driver_zero_stride*`, `agc_driver_relative*`, `agc_driver_mesh*`, `agc_driver_stencil_replay*`, `agc_embedded_vertex*`, `agc_driver_indirect*`, `agc_index_*`, `agc_driver_pm4*`) with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` (1.4.363) and `VK_LOADER_DEBUG=layer`: | | `main` 441fa65119 | this change (8a0fcdd825) | |---|---|---| | Passed / failed | 171 / 0 | 171 / 0 | | Validation layer inserted | 223 | 223 | | `VUID-` lines | 0 | 0 | Rebased onto `origin/main` 0af6efad52 as 6080bb0b93 (resolving conflicts with merged #26775 by preserving `!wholeRange` on `firstByte` in `Draw.cpp` and the 5-argument `attempt(...)` signature in `tests/Recorder.cpp`). Re-verified on the same RX 6800 with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` (1.4.363.0), `VK_LOADER_DEBUG=layer`: - Focused 20-test set (`agc_driver_draw_offset_indices*`, `agc_index_in_place_behind_writer`, `agc_driver_graphics`, `agc_driver_list_restart*`, `agc_driver_indirect*`, `agc_driver_zero_stride*`, `agc_driver_recorder`): **20 / 20 passed** on both `origin/main` 0af6efad52 and 6080bb0b93, 34 validation layer inserts on both, **0 `VUID-` lines**. - Negative control (checking out `origin/main` 0af6efad52's `Draw.cpp` and `IndirectDraw.cpp` against 6080bb0b93's tests): **4 / 4 failed** (`agc_driver_draw_offset_indices`, `_poisoned`, `_poisoned_in_place` with `AGC driver: draw vertex offset overflow`, and `agc_index_in_place_behind_writer` on the -2147483648 case); all 4 pass on 6080bb0b93. - Earlier 171-test full sweep on 441fa65119 / 8a0fcdd825 above; `tools/check_conventions.py --base origin/main` and `tools/debt_fold.py --check` pass on 6080bb0b93. Forza Horizon 5 (PPSA22327 01.685.672), local stack of open PRs: - **What the game does:** an indexed triangle-list draw with 16-bit indices from 0x214 to 0x1698 and a base vertex of 0xfffffdec (-532), so it reads vertices 0 to 0x1484. - **Without this change:** the refusal stopped 3 runs, at 252.7 s, 261.1 s and 259.9 s. - **With this change:** 3 runs on d85e9ac04d, none with it. All three ran 610 s, past the point where it stopped, to a later, unrelated freeze. 4f888baf4a, 8a0fcdd825 and rebased 6080bb0b93 were not run in the game. `py -3 tools/check_conventions.py --base origin/main` and `py -3 tools/debt_fold.py --check` pass. `py -3 tools/pr_overlap.py --branch fix/agc-negative-base-vertex` (2,508 open PRs): all 83 mergeable PRs that share files merge cleanly. The 45 PRs that conflict with `main` were searched by hand; #9897 and #14032 set `draw.firstVertex` in tests, #10193, #13928 and #22647 change where the zero-fetch vertex attributes come from, and #22647 calls `FoldDrawOffsets`; none takes the base vertex as signed or changes the fold or the in-place index check. Not tested: a negative base vertex through an indirect draw's arguments in a title, the expanded-index path with a negative base vertex in a title, other GPUs, Linux. ### Related Part of the Forza Horizon 5 (PPSA22327) bring-up, #25152. It was found on the stack of PRs the game needed (#24960, #24994, #25151, #25867–#25874, #26034 and #26035 are now merged; #23688, #23545, #21479, #11825, #23778, #21155, #22306 and #21199) and stands alone: it applies to `main` by itself and needs none of them to build or pass its tests. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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) and the licence notice of code adapted from upstream (see AGENTS.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 - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: PPSA22327 #25152 - [x] GPUs tested: AMD Radeon RX 6800 (vendor=0x1002, device=0x73bf), AMD proprietary driver 26.10.1 (Windows driver 32.0.21045.16010, Vulkan 1.4.315), Windows 11 Pro (build 26300); Khronos validation layer 1.4.363.0 on `main` and this change, 0 VUIDs - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Corrected vertex-offset handling for indexed draws, including negative offsets and values near the supported range limits. * Improved validation of indexed-draw vertex ranges to prevent invalid or overflowing ranges from being accepted. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
MarcZX10 commented 2026-11-23 04:55:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T04:55:44Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: fix the expanded-index range check so it also rejects a negative resulting vertex index.

What I ran

Reviewed head d85e9ac04d8aa897d51921aaf790911658a49154. Read description.md, commits.md, manifest.json, diff.patch, and the full text of both changed files in review/manifest.json. No commands or tests were run; repo_read.py was unavailable in this session.

Results

Check Result Note
Changed code review failed Expanded-index check misses lower bound
Tests not run Author-reported results not independently verified

Findings

Blocking

  • Draw.cpp:1974: The expanded-index path checks only maxIdx + firstVertex <= UINT32_MAX. With a signed negative base vertex, this permits a lowest index smaller than the magnitude of the offset. For example, index 2 with offset -3 passes the upper-bound check, then the indexed range check at line 2096 rejects the same invalid draw later. The expanded path must validate the lower bound too, before the subsequent additions and index limit checks.

Non-blocking

None.

Not verified

The test file’s full text was included in the changed-file bundle, but the reader returned only the requested out-of-range slice for the test read; the changed test lines are visible in diff.patch. No test execution, author-reported validation, hardware behavior, or other repository context was independently verified. No files were excluded according to manifest.json; review/files.json was not available.

To get this to a good state

Add the lower-bound validation to the expanded-index path and run the focused draw tests, including a negative offset whose lowest expanded index would become negative.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6016742793 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26036#pullrequestreview-6016742793). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-23T04:55:44Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: fix the expanded-index range check so it also rejects a negative resulting vertex index. ## What I ran Reviewed head `d85e9ac04d8aa897d51921aaf790911658a49154`. Read `description.md`, `commits.md`, `manifest.json`, `diff.patch`, and the full text of both changed files in `review/manifest.json`. No commands or tests were run; `repo_read.py` was unavailable in this session. ## Results | Check | Result | Note | |---|---|---| | Changed code review | failed | Expanded-index check misses lower bound | | Tests | not run | Author-reported results not independently verified | ## Findings ### Blocking - `Draw.cpp:1974`: The expanded-index path checks only `maxIdx + firstVertex <= UINT32_MAX`. With a signed negative base vertex, this permits a lowest index smaller than the magnitude of the offset. For example, index 2 with offset -3 passes the upper-bound check, then the indexed range check at line 2096 rejects the same invalid draw later. The expanded path must validate the lower bound too, before the subsequent additions and index limit checks. ### Non-blocking None. ## Not verified The test file’s full text was included in the changed-file bundle, but the reader returned only the requested out-of-range slice for the test read; the changed test lines are visible in `diff.patch`. No test execution, author-reported validation, hardware behavior, or other repository context was independently verified. No files were excluded according to `manifest.json`; `review/files.json` was not available. ## To get this to a good state Add the lower-bound validation to the expanded-index path and run the focused draw tests, including a negative offset whose lowest expanded index would become negative.
MarcZX10 commented 2026-11-23 05:31:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T05:31:11Z.

Review: APPROVED


Reviewed — looks good

The reviewed change handles signed indexed base vertices and adds regression coverage for valid and invalid ranges; the available evidence supports merging.

What I ran

Reviewed head 4f888baf4a6b016330ecf057da5fc1e7647d07dd using repo_read.py to inspect the prepared diff and relevant code ranges. No commands or tests were run by me.

Read: description.md, commits.md, manifest.json, diff.patch, and all relevant ranges of Draw.cpp and DrawOffsetIndices.cpp. Both files listed in the manifest as reviewed were read. files.json was unavailable through the reader; its exclusions were not verified.

Results

Check Result Note
Diff and code review passed Two changed files reviewed
Tests run by reviewer not run Author reports focused tests passed
Excluded files not verified files.json unavailable

Findings

Blocking

None.

Non-blocking

None.

Not verified

I did not run tests or independently verify the author's test, hardware, or game-run reports. Excluded-file details were not available. The review was based on the prepared diff and the two changed files listed in the manifest.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6016954752 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26036#pullrequestreview-6016954752). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-23T05:31:11Z. **Review:** APPROVED --- # Reviewed — looks good The reviewed change handles signed indexed base vertices and adds regression coverage for valid and invalid ranges; the available evidence supports merging. ## What I ran Reviewed head `4f888baf4a6b016330ecf057da5fc1e7647d07dd` using `repo_read.py` to inspect the prepared diff and relevant code ranges. No commands or tests were run by me. Read: `description.md`, `commits.md`, `manifest.json`, `diff.patch`, and all relevant ranges of `Draw.cpp` and `DrawOffsetIndices.cpp`. Both files listed in the manifest as reviewed were read. `files.json` was unavailable through the reader; its exclusions were not verified. ## Results | Check | Result | Note | |---|---|---| | Diff and code review | passed | Two changed files reviewed | | Tests run by reviewer | not run | Author reports focused tests passed | | Excluded files | not verified | `files.json` unavailable | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified I did not run tests or independently verify the author's test, hardware, or game-run reports. Excluded-file details were not available. The review was based on the prepared diff and the two changed files listed in the manifest. ## To get this to a good state Nothing is required.
mihiii1337 commented 2026-11-23 07:03:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mihiii1337 on 2026-11-23T07:03:58Z.

Review: CHANGES_REQUESTED


Reviewed exact head 4f888baf4a6b016330ecf057da5fc1e7647d07dd. The new range checks correctly interpret the final indexed base vertex as signed, but the producer can still reject a valid signed result before those checks.

Driver::FoldDrawOffsets adds the shader/user-SGPR word to DrawParameters::firstVertex with an unsigned overflow test. For a direct indexed draw with GE_INDX_OFFSET=+3 and a folded shader base-vertex word of -3 (0xfffffffd), the correct final signed base vertex is 0. The current check treats the second word as 4294967293 and throws draw vertex offset overflow. The reverse -3 + +3 case has the same problem. The two new indexed fixtures both seed firstVertex=0, so they do not cover composition with the PM4 offset.

Please combine the two words in signed/widened arithmetic for indexed draws, check the representable final signed offset, and keep the existing unsigned behavior for non-indexed starts. Add a regression through the existing FoldedDraw wrapper with nonzero firstVertex, e.g. +3 plus shader -3 over {0,1,2}.

A local CPU probe using byte-verified copies of the exact drawUserWord, FoldDrawOffsets, and changed range logic reproduced both mixed-direction rejections and passed 12 boundary/negative controls; the exact changed Draw.cpp also passed a WinLibs compile-only check. Hosted Windows is green but its logged selection did not run draw_offset_indices; the author and peer GPU runs cover the current fixtures. I did not run a local GPU test.

The overlapping index-expansion hunk in #26041 merges cleanly with this head; this finding is in the unchanged producer-side folding code.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6017644358 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26036#pullrequestreview-6017644358). Originally posted by [mihiii1337](https://github.com/mihiii1337) on 2026-11-23T07:03:58Z. **Review:** CHANGES_REQUESTED --- Reviewed exact head `4f888baf4a6b016330ecf057da5fc1e7647d07dd`. The new range checks correctly interpret the final indexed base vertex as signed, but the producer can still reject a valid signed result before those checks. `Driver::FoldDrawOffsets` adds the shader/user-SGPR word to `DrawParameters::firstVertex` with an unsigned overflow test. For a direct indexed draw with `GE_INDX_OFFSET=+3` and a folded shader base-vertex word of `-3` (`0xfffffffd`), the correct final signed base vertex is 0. The current check treats the second word as `4294967293` and throws `draw vertex offset overflow`. The reverse `-3 + +3` case has the same problem. The two new indexed fixtures both seed `firstVertex=0`, so they do not cover composition with the PM4 offset. Please combine the two words in signed/widened arithmetic for indexed draws, check the representable final signed offset, and keep the existing unsigned behavior for non-indexed starts. Add a regression through the existing `FoldedDraw` wrapper with nonzero `firstVertex`, e.g. `+3` plus shader `-3` over `{0,1,2}`. A local CPU probe using byte-verified copies of the exact `drawUserWord`, `FoldDrawOffsets`, and changed range logic reproduced both mixed-direction rejections and passed 12 boundary/negative controls; the exact changed `Draw.cpp` also passed a WinLibs compile-only check. Hosted Windows is green but its logged selection did not run `draw_offset_indices`; the author and peer GPU runs cover the current fixtures. I did not run a local GPU test. The overlapping index-expansion hunk in #26041 merges cleanly with this head; this finding is in the unchanged producer-side folding code. AI-assisted: yes.
mihiii1337 commented 2026-11-23 08:35:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mihiii1337 on 2026-11-23T08:35:19Z.

Review: APPROVED


Re-reviewed fix head 8a0fcdd82559dd2a7e238653b46cf61fcb731cef. This resolves both parts of my earlier finding: indexed offset folding now uses a signed wide intermediate with checked narrowing, and every negative final indexed offset is routed away from the in-place writer.

Exact-source CPU A/B results:

  • indexed folding mismatches: 90/196 on 4f888baf → 0/196 here, including both +3 + (-3) cancellation directions and signed upper overflow;
  • unsigned/non-indexed controls: 0/196 on both revisions;
  • extracted full InPlaceIndexBehindWriter gate with unrelated gates controlled: 4/28 → 0/28.

All four changed translation units pass WinLibs C++20 syntax checks. The recorder fixture generated its ten exact shaders with the previously built CPU glslang and current embed script, without Vulkan initialization. The new folded-draw tests cover positive/negative cancellation, signed overflow and returned vertex/instance IDs; the recorder cases discriminate the in-place gate.

Scope nuance is accurate: INT_MIN is a gate counterexample for 16-bit indices, not an otherwise renderable 16-bit draw; valid small negative offsets already selected the copy path before this follow-up. The production signed-fold fix remains independently necessary and proven. The author reports 171/171 focused tests on base and head with 223 validation-layer insertions and 0 VUIDs, plus negative controls. I ran no local GPU test. Merge preview with #26041 and current main is clean; hosted Windows is still running with no failures.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6018588174 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26036#pullrequestreview-6018588174). Originally posted by [mihiii1337](https://github.com/mihiii1337) on 2026-11-23T08:35:19Z. **Review:** APPROVED --- Re-reviewed fix head `8a0fcdd82559dd2a7e238653b46cf61fcb731cef`. This resolves both parts of my earlier finding: indexed offset folding now uses a signed wide intermediate with checked narrowing, and every negative final indexed offset is routed away from the in-place writer. Exact-source CPU A/B results: - indexed folding mismatches: 90/196 on `4f888baf` → 0/196 here, including both `+3 + (-3)` cancellation directions and signed upper overflow; - unsigned/non-indexed controls: 0/196 on both revisions; - extracted full `InPlaceIndexBehindWriter` gate with unrelated gates controlled: 4/28 → 0/28. All four changed translation units pass WinLibs C++20 syntax checks. The recorder fixture generated its ten exact shaders with the previously built CPU glslang and current embed script, without Vulkan initialization. The new folded-draw tests cover positive/negative cancellation, signed overflow and returned vertex/instance IDs; the recorder cases discriminate the in-place gate. Scope nuance is accurate: `INT_MIN` is a gate counterexample for 16-bit indices, not an otherwise renderable 16-bit draw; valid small negative offsets already selected the copy path before this follow-up. The production signed-fold fix remains independently necessary and proven. The author reports 171/171 focused tests on base and head with 223 validation-layer insertions and 0 VUIDs, plus negative controls. I ran no local GPU test. Merge preview with #26041 and current main is clean; hosted Windows is still running with no failures. AI-assisted: yes.
MarcZX10 commented 2026-11-23 08:36:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T08:36:57Z.

Review: APPROVED


Reviewed — looks good

The indexed draw changes and the added regression cases were reviewed at head 8a0fcdd82559dd2a7e238653b46cf61fcb731cef; no blocking defect was found in the code read.

What I ran

No commands or tests were run. I read the prepared review bundle and used the pinned repository reader for the changed test file excluded from the bundle.

Results

Check Result Note
Change and targeted code review passed Signed offset handling inspected
Tests and build not run Author-reported results were not rerun

Findings

Blocking

None.

Non-blocking

None.

Not verified

core/libs/prx/libSceAgcDriver/tests/Recorder.cpp was not read in full; its changed lines and surrounding function were read from the pinned head. No commands or tests were run. The author-reported test results and game behavior were not independently verified. Other GPUs, Linux, and title behavior for indirect negative offsets and expanded-index draws were not verified.

Files read: review/description.md, review/commits.md, review/manifest.json, review/diff.patch; core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/IndirectDraw.cpp, core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp, core/libs/prx/libSceAgcDriver/tests/Recorder.cpp (targeted range), and core/libs/prx/libSceAgcDriver/tests/execution/DrawOffsetIndices.cpp (targeted ranges). Excluded from full-text bundle: core/libs/prx/libSceAgcDriver/tests/Recorder.cpp because it was too large.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6018604175 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26036#pullrequestreview-6018604175). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-23T08:36:57Z. **Review:** APPROVED --- # Reviewed — looks good The indexed draw changes and the added regression cases were reviewed at head `8a0fcdd82559dd2a7e238653b46cf61fcb731cef`; no blocking defect was found in the code read. ## What I ran No commands or tests were run. I read the prepared review bundle and used the pinned repository reader for the changed test file excluded from the bundle. ## Results | Check | Result | Note | |---|---|---| | Change and targeted code review | passed | Signed offset handling inspected | | Tests and build | not run | Author-reported results were not rerun | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified `core/libs/prx/libSceAgcDriver/tests/Recorder.cpp` was not read in full; its changed lines and surrounding function were read from the pinned head. No commands or tests were run. The author-reported test results and game behavior were not independently verified. Other GPUs, Linux, and title behavior for indirect negative offsets and expanded-index draws were not verified. Files read: `review/description.md`, `review/commits.md`, `review/manifest.json`, `review/diff.patch`; `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/IndirectDraw.cpp`, `core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp`, `core/libs/prx/libSceAgcDriver/tests/Recorder.cpp` (targeted range), and `core/libs/prx/libSceAgcDriver/tests/execution/DrawOffsetIndices.cpp` (targeted ranges). Excluded from full-text bundle: `core/libs/prx/libSceAgcDriver/tests/Recorder.cpp` because it was too large. ## To get this to a good state Nothing is required.
MarcZX10 commented 2026-11-26 11:00:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-26T11:00:00Z.

Review: APPROVED


Reviewed — looks good

Nothing in the inspected changes shows a blocking defect, and the tests reported by the author cover the signed offset cases added here.

What I ran

Reviewed head 6080bb0b9372ff9d6eae0f170212093c52b57f80. No commands or tests were run; test results in the description are author-reported.

Results

Check Result Note
Source review passed Changed runtime paths and tests inspected
Tests not run Author reports focused tests passed
Negative control not run Author reports four expected failures

Findings

Blocking

None.

Non-blocking

None.

Not verified

No test execution was performed. The game runs, other GPUs, Linux, and indirect or expanded-index negative-offset behavior in titles were not verified. Recorder.cpp was excluded from the prepared review bundle; its changed lines were read through the pinned-head reader, but its surrounding full test context was not reviewed. The other changed files were included and inspected at the relevant changed sections.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6072947215 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26036#pullrequestreview-6072947215). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-26T11:00:00Z. **Review:** APPROVED --- # Reviewed — looks good Nothing in the inspected changes shows a blocking defect, and the tests reported by the author cover the signed offset cases added here. ## What I ran Reviewed head `6080bb0b9372ff9d6eae0f170212093c52b57f80`. No commands or tests were run; test results in the description are author-reported. ## Results | Check | Result | Note | |---|---|---| | Source review | passed | Changed runtime paths and tests inspected | | Tests | not run | Author reports focused tests passed | | Negative control | not run | Author reports four expected failures | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified No test execution was performed. The game runs, other GPUs, Linux, and indirect or expanded-index negative-offset behavior in titles were not verified. `Recorder.cpp` was excluded from the prepared review bundle; its changed lines were read through the pinned-head reader, but its surrounding full test context was not reviewed. The other changed files were included and inspected at the relevant changed sections. ## To get this to a good state Nothing is required.
MarcZX10 commented 2026-11-29 23:04:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-29T23:04:02Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the review supports merging.

What I ran

Reviewed head 8f5ca2b793c6210e10e065bae0fccc4d504938b2. I did not run commands or tests. I read the prepared description, commits, manifest, and diff, plus the relevant changed functions and test additions at the pinned head.

Results

Check Result Note
Code review passed Signed indexed ranges checked
Tests in this review not run Author-reported runs only
Negative control not run Author reports four failures on prior code

Findings

Blocking

None.

Non-blocking

None.

Not verified

I read the full text for IndirectDraw.cpp, Draw.cpp, and DrawOffsetIndices.cpp, and the changed Recorder.cpp lines through the pinned reader. All four changed files marked reviewed in the manifest were read; Recorder.cpp was excluded from the review folder because of its size, so I read only its changed region. I did not run the reported test suites or inspect unrelated file contents. Console behavior, other GPUs, Linux, and the title scenarios identified by the author as untested remain unverified.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6105269424 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26036#pullrequestreview-6105269424). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-29T23:04:02Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the review supports merging. ## What I ran Reviewed head `8f5ca2b793c6210e10e065bae0fccc4d504938b2`. I did not run commands or tests. I read the prepared description, commits, manifest, and diff, plus the relevant changed functions and test additions at the pinned head. ## Results | Check | Result | Note | |---|---|---| | Code review | passed | Signed indexed ranges checked | | Tests in this review | not run | Author-reported runs only | | Negative control | not run | Author reports four failures on prior code | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified I read the full text for `IndirectDraw.cpp`, `Draw.cpp`, and `DrawOffsetIndices.cpp`, and the changed `Recorder.cpp` lines through the pinned reader. All four changed files marked `reviewed` in the manifest were read; `Recorder.cpp` was excluded from the review folder because of its size, so I read only its changed region. I did not run the reported test suites or inspect unrelated file contents. Console behavior, other GPUs, Linux, and the title scenarios identified by the author as untested remain unverified. ## To get this to a good state Nothing is required.
Plyxen commented 2026-12-03 06:03:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-12-03T06:03:46Z.

Review: APPROVED


I read the diff at 8f5ca2b793. Windows 11, GCC 15.2, merged into main at cf556db18c3 together with other open PRs (so not an isolated build), with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 and VK_LAYER_KHRONOS_validation on an RTX 5080 (621.24) and a Radeon iGPU (26.11.2).

  • the 186 tests of agc_driver_draw_offset_indices_tests and agc_driver_recorder_tests (2 of them skip on the Radeon): pass on both GPUs. The loader log shows the layer inserted and no "was not found" line, and neither run has a VUID- or SYNC-HAZARD line.
  • Control (same tree and tests, the changed files of those PRs put back to main's): agc_driver_draw_offset_indices, its two poisoned variants and agc_index_in_place_behind_writer fail on both GPUs: "draw vertex offset overflow", and a 16-bit index range "whose vertex offset of -2147483648 takes every index below vertex 0". The others pass.

Not checked: a title.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6164480350 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26036#pullrequestreview-6164480350). Originally posted by [Plyxen](https://github.com/Plyxen) on 2026-12-03T06:03:46Z. **Review:** APPROVED --- I read the diff at `8f5ca2b793`. Windows 11, GCC 15.2, merged into `main` at `cf556db18c3` together with other open PRs (so not an isolated build), with `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1` and `VK_LAYER_KHRONOS_validation` on an RTX 5080 (621.24) and a Radeon iGPU (26.11.2). - the 186 tests of `agc_driver_draw_offset_indices_tests` and `agc_driver_recorder_tests` (2 of them skip on the Radeon): pass on both GPUs. The loader log shows the layer inserted and no "was not found" line, and neither run has a `VUID-` or `SYNC-HAZARD` line. - Control (same tree and tests, the changed files of those PRs put back to `main`'s): `agc_driver_draw_offset_indices`, its two poisoned variants and `agc_index_in_place_behind_writer` fail on both GPUs: "draw vertex offset overflow", and a 16-bit index range "whose vertex offset of -2147483648 takes every index below vertex 0". The others pass. Not checked: a title. AI-assisted: yes (Claude Code)
ligmaSec commented 2026-12-03 21:29:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T21:29:16Z.

Review: COMMENTED


The signed widening covers both the offset fold and post-index range checks. The new fixture covers opposite-sign register offsets, both signed fold limits, a lowest effective vertex of zero and a quad that crosses below zero. Please add a successful expanded quad with a negative base and all raw indices above zero. That would exercise carrying the expanded minimum through to the vertex upload and alias calculation, beyond the expanded path's rejection case. The paired draw-offset and behind-writer tests are queued on Linux lavapipe.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6178915985 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26036#pullrequestreview-6178915985). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T21:29:16Z. **Review:** COMMENTED --- The signed widening covers both the offset fold and post-index range checks. The new fixture covers opposite-sign register offsets, both signed fold limits, a lowest effective vertex of zero and a quad that crosses below zero. Please add a successful expanded quad with a negative base and all raw indices above zero. That would exercise carrying the expanded minimum through to the vertex upload and alias calculation, beyond the expanded path's rejection case. The paired draw-offset and behind-writer tests are queued on Linux lavapipe. AI-assisted: yes.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/26036:upstream-pr/26036'
git switch 'upstream-pr/26036'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/26036'
git switch 'upstream-pr/26036'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/26036'
git switch 'upstream-pr/26036'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/26036'
git switch 'main'
git merge --squash 'upstream-pr/26036'
git switch 'main'
git merge --ff-only 'upstream-pr/26036'
git switch 'main'
git merge 'upstream-pr/26036'
git push origin 'main'
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!26036
No description provided.